How to override the behavior of Spring @Autowired

后端 未结 3 1163
北荒
北荒 2020-12-19 05:06

A little background:

I am Using Spring 2.5, and specifically Spring IOC and annotations.

I am using @Autowired in my code (the Autowiring is don

3条回答
  •  梦毁少年i
    2020-12-19 05:42

    I agree with Didier. Here is an example of how you can exclude the implementations that you want to mock in your test application context.

    
            
    
    

    Include this application context in your test as follows :

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations={"classpath:/applicationContext-test.xml"})
    public class MyTest {....}
    

提交回复
热议问题