【发布时间】:2010-12-09 07:46:50
【问题描述】:
我有一个注入两个属性的类:
private CustomRatesService customRatesService;
private TokenAuthenticator tokenAuthenticator;
public void setCustomRatesService(CustomRatesService customRatesService) {
this.customRatesService = customRatesService;
}
public void setTokenAuthenticator(TokenAuthenticator tokenAuthenticator) {
this.tokenAuthenticator = tokenAuthenticator;
}
这是 applicationContext.xml:
<bean id="customRatesServiceBean" class="com.ms.rate.service.SetCustomRatesResourceImpl">
<property name="tokenAuthenticator" ref="tokenAuthenticator"/>
<property name="customRatesService" ref="customRatesService"/>
</bean>
还有一个包含 bean 的 services.xml 文件
<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>
但是,如果我在方法中设置断点,我可以看到 tokenAuthenticator 始终为 null,尽管其他属性有值
会不会是因为这个类有一个WebService注解?我完全迷惑了。
我已经到处调试了,我可以看到:
tokenAuthenticator bean 肯定会被创建。 另外,它肯定会被注射!如果我从类中的注入方法中打印出引用,我可以看到一个有效的引用。当我去使用它时它只是空的..
非常感谢任何想法!
谢谢!
【问题讨论】: