I am a Spring neophyte who is working on a large Spring project that has an extensive relationship between Spring beans. I am trying to write some integration tests that perform subsets of the overall functionality of an application. For this, I would like to redefine some of them. For example, suppose I have a class
public class MyDataServiceImpl implements MyDataService { @Qualifier("notNeededForMyDataServiceTest") @Autowired private NotNeededForMyDataServiceTest notNeededForMyDataServiceTest;
and context file with:
<bean id="myDataService" class="MyDataServiceImpl"> </bean>
In my test, I do not need to use the notNeededForMyDataServiceTest field. Is there a way to override the @Autowired annotation and set notNeededForMyDataServiceTest to null, possibly in an XML file? I do not want to change any of the Java classes, but I want to avoid the (problematic) configuration of notNeededForMyDataServiceTest .
I tried to do:
<bean id="myDataService" class="MyDataServiceImpl"> <property name="notNeededForMyDataServiceTest"><null/></property> </bean>
This does not work. IntelliJ tells me: “Cannot resolve the“ notNeededForMyDataServiceTest ”property, apparently because there are no getters and setters for this field.
I am using Spring Framework 3.1.3.
source share