1.在Spring的applicationContext.xml(主容器)中,将Controller(控制器)的注解打消掉
2.在SpringMVC配置文件中将Service注解给去掉
<context:component-scan base-package="com">
<context:exclude-filter type="annotation" experession="org.springframework.stereotype.Controller" />
</context:component-scan>2.在SpringMVC配置文件中将Service注解给去掉
<context:component-scan base-package="com">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>
本文详细介绍了在Spring框架中如何通过XML配置文件排除Controller和Service注解,实现特定组件的不自动装配,对于理解Spring组件扫描机制和自定义装配逻辑有重要指导意义。
334

被折叠的 条评论
为什么被折叠?



