如何在context:component-scan
元素的spring-servlet.xml文件中添加多個包?上下文中的多個包:組件掃描,彈性配置
我已經試過
<context:component-scan base-package="z.y.z.service" base-package="x.y.z.controller" />
和
<context:component-scan base-package="x.y.z.service, x.y.z.controller" />
和
<context:component-scan base-package="x.y.z.service" />
<context:component-scan base-package="x.y.z.controller" />
,但得到的錯誤:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [x.y.z.dao.daoservice.LoginDAO] found for dependency:
是的,這麼認爲(+1) – 2011-03-11 13:25:45
這個答案意味着沒有遞歸的基礎包的成員但是那裏是:http://stackoverflow.com/questions/7774295/spring-xml-file-configuration-hierarchy-help-explanation/7774597#7774597。我會建議稍微修改一下這個答案,以便說清楚。 – djangofan 2015-10-27 17:59:44