I have a class that gets two properties injected into it:
private CustomRatesService customRatesService;
private TokenAuthenticator tokenAuthenticator;
public void setCustomRatesService(CustomRatesService customRatesService) {
this.customRatesService = customRatesService;
}
public void setTokenAuthenticator(TokenAuthenticator tokenAuthenticator) {
this.tokenAuthenticator = tokenAuthenticator;
}
Here's the applicationContext.xml:
<bean id="customRatesServiceBean" class="com.ms.rate.service.SetCustomRatesResourceImpl">
<property name="tokenAuthenticator" ref="tokenAuthenticator"/>
<property name="customRatesService" ref="customRatesService"/>
</be开发者_运维知识库an>
And a services.xml file containing the beans
<bean id="customRatesService" class="com.ms.rate.service.CustomRatesServiceImpl">
<property name="customRateDao" ref="customRateDao" />
</bean>
<bean id="tokenAuthenticator" class="com.ms.rate.service.TokenAuthenticatorImpl">
<property name="authenticationUrl" value="${AUTHENTICATION_URL}"/>
</bean>
Yet if I put a breakpoint in a method, I can see that the tokenAuthenticator is always null, though the other property has a value
Could it be because the class has a WebService annotation? I'm completely baffled.
I've put debug all over the place and I can see:
The tokenAuthenticator bean is definitely getting created. Plus, it is definitely getting injected! I can see a valid reference if I print out the reference from the injecting method in the class. It's just null when I go to use it..
Very grateful for any thoughts!!
Thanks!
Ok it turned out to be an idiotic mistake on my part.
For some reason I had used that class as the implementation for two beans. The debugger was showing me the injector getting called, but on the creation of the bean I wasn't using. On the bean I was using, I hadn't added the second property. Gah...
Just leaving this up here in case anyone else does something so foolish, and if nothing else then as a little self-humiliation to discourage me from doing this again.
精彩评论