나는 간단한 것을 놓치고 싶습니다. bar는 junit 테스트에서 자동으로 실행되지만, foo 내부의 bar는 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