当前位置: 代码迷 >> Java Web开发 >> spring xml中定义的bean怎么使用注解定义的bean
  详细解决方案

spring xml中定义的bean怎么使用注解定义的bean

热度:86   发布时间:2016-04-12 22:08:31.0
spring xml中定义的bean如何使用注解定义的bean
假设我再xml中定义一个bean:Test1,我又有另一个bean:Test2,(通过注解定义如@service),我现在想在Test1中拿到Test2,但是现在报Test2未定义,注入不进Test1.我该怎么解决

------解决方案--------------------
在你applicationContext.xml 里面加上

<beans 
//...
xmlns:context="http://www.springframework.org/schema/context"
//...
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd">
//...
 
<context:annotation-config />
//...
</beans>
------解决方案--------------------
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/bbs/entity</value>
</list>
</property>

要配置这个
  相关解决方案