【实用小技巧】spring与springmvc自动扫描包重复的问题解决
2018-05-23 23:09
435 查看
spring对应配置文件为:
<!-- 配置自动扫描的包,此时要排除Controller --> <context:component-scan base-package="com.lw"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan>
springmvc对应的配置文件为:
<!-- user-default-filters 与 include-filter搭配使用 实现仅仅扫描Controller注解 --> <context:component-scan base-package="com.lw" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan>
注:属性user-default-filters官方介绍:
Attribute : use-default-filters Indicates whether automatic detection of classes annotated with @Component, @Repository, @Service, or @Controller should be enabled. Default is "true".
相关文章推荐
- 解决spring、springMVC重复扫描导致事务失效的问题
- 解决spring、springMVC重复扫描导致事务失效的问题
- 解决Spring和SpringMVC扫描注解类的冲突问题
- Spring和SpringMVC自动扫描注解类的冲突问题
- 关于spring和springmvc的xml自动扫描配置问题
- Spring 与 SpringMVC Bean重复扫描问题
- spring和springmvc的扫描组件的配置,解决多次实例化问题
- 解决spring 自动扫描包的时候出现 service无法自动注入的问题
- ECLIPSE中MAVEN构建spring 多模块工程jar包不能自动扫描问题解决办法
- 解决Spring在某些条件下无法自动注入的问题
- mybatis整合spring、springmvc时业务层无法进行事务回滚问题解决
- 关于SpringBoot bean无法注入的问题(与文件包位置有关)改变自动扫描的包
- activiti解决实现ExecutionListener spring 自动注入@Autowired为null问题
- 解决Spring+Quartz无法自动注入bean问题
- 解决在spring配置文件中包扫描无效问题
- Spring和SpringMVC的包扫描问题
- Proxool+hibernate+spring时事务自动回滚导致无法提交的问题解决
- 解决Spring定时计划任务重复执行两次(实例被构造两次)问题的方法
- 关于SpringBoot bean无法注入的问题(与文件包位置有关)改变自动扫描的包
- 关于SpringBoot bean无法注入的问题(与文件包位置有关)改变自动扫描的包