如果您使用的是Spring
Stereotype批注(
@Service,
@Component…),则可能在spring配置中包括了将
<context:component-scan/>其拾取的元素。可以这样做,但是它会自动
CommonAnnotationBeanPostProcessor在应用程序上下文中注册a
,如该链接中第二个注释上方所述。
包含的问题
CommonAnnotationBeanPostProcessor是Spring处理
@Resource注释,并将尝试从其应用程序上下文注入bean。您可以注册自己的
CommonAnnotationBeanPostProcessorbean,并
@Resource通过将bean设置为
alwaysUseJndiLookup属性来配置bean,以指示Spring允许直接JNDI访问这些bean
true。
<bean > <property name="alwaysUseJndiLookup" value="true"/></bean>
请注意链接文档中的注释:
注意:默认的CommonAnnotationBeanPostProcessor将通过“ context:annotation-config”和“
context:component-scan” XML标签进行注册。如果要指定自定义CommonAnnotationBeanPostProcessor
bean定义,请删除或关闭那里的默认注释配置!



