私は単純なものがないと確信しています。バーはjunitテストでautowiredになりますが、なぜfooのバーはautowiredにならないのですか?junitテストでAutowireが動作しない
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"beans.xml"})
public class BarTest {
@Autowired
Object bar;
@Test
public void testBar() throws Exception {
//this works
assertEquals("expected", bar.someMethod());
//this doesn't work, because the bar object inside foo isn't autowired?
Foo foo = new Foo();
assertEquals("expected", foo.someMethodThatUsesBar());
}
}
"bar inside foo"とは何を意味していますか? – skaffman