spring大小容器問題解決方案

spring大小容器問題解決service注入失敗問題:

1:原理

:如圖
spring大小容器問題解決方案

2:解決方案

:
在以下springMVC-servlet.xml,applicationContext.xml倆個配置文件中分別開啓注解掃描mvc:annotation-driven</mvc:annotation-driven>
然後分別在springMVC-servlet.xml中增加控制只掃描controller,配置如下:
<context:component-scan base-package=“com.astp.screen” use-default-filters=“false”>
<context:include-filter type=“annotation” expression=“org.springframework.stereotype.Controller” />
</context:component-scan>
在applicationContext.xml增加掃描控制除controller外:配置如下:
<context:component-scan base-package=“com.astp.screen”>
<context:exclude-filter type=“annotation” expression=“org.springframework.stereotype.Controller”/>
</context:component-scan>
具體如圖:
spring大小容器問題解決方案
spring大小容器問題解決方案