两个XML配置中,需要把扫描的类区分出来。
spring-mybatis.xml(application.xml):
<!-- 自动扫描 -->
<context:component-scan base-package="com.maiken" >
<!-- 父容器不加载 action -->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
spring-mvc.xml
<!-- 自动扫描该包 -->
<context:component-scan base-package="com.maiken" >
<!-- 子容器不加载服务层 -->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>