为什么80%的码农都做不了架构师?>>>   

首先,如果不配置事务在哪里扫描都是可以的,但是这是不可能的,所以扫描的时候就需要有先后的顺序。

顺序:spring负责除controller层之外所有注解的扫描,将controller层的扫描放到MVC的配置文件中。

spring配置文件:

<context:component-scan base-package="com" use-default-filters=false>   <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />   </context:component-scan>  

springMVC配置文件:

<context:component-scan base-package="com" use-default-filters=false>   <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />   <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />   </context:component-scan> 

按照如上顺序,springMVC只扫描controller然后其他的都交由spring来扫描

ps:当base-package包含controller层、service层、Repository层时,需要设置use-default-filters,否则会扫描所有的注解,不区分。

转载于:https://my.oschina.net/mrfu/blog/1504010

spring与springMVC配置扫描的问题相关推荐

  1. 配置spring、SpringMVC,mybatis进行整合

    springframwork的官网 spring-projects/spring-mvc-showcase https://github.com/spring-projects/spring-mvc- ...

  2. 第9步 spring 配置 springmvc配置

    spring配置 有5个网址   springboot 再讲一遍  spring的学习最好的方法是运行  官方demo  学习它里面的配置   . 我们不可能一下子理解spring里面的源码 spri ...

  3. spring boot web开发------自定义springmvc配置

    1.如何自定义springmvc配置 旧的springmvc配置文件 <?xml version="1.0" encoding="UTF-8"?> ...

  4. springMVC+Spring+mybatis整合配置版与注解版

    springMVC+Spring+mybatis整合 , 使用配置版来完成: -----------------------------前端 1.创建web系统,导入jar包: spring的jar包 ...

  5. springmvc 配置和spring配置?

    最近在接触mybatis,之间使用springmvc时,配置文件一直是,web.xml+XX-servlet.xml 的配置(xx为web.xml中servlet name名称). 为了整合mybat ...

  6. spring boot实现WebMvcConfigurer接口定制SpringMvc配置

    文章目录 自定义静态资源映射 addResourceHandlers() 拦截器 addInterceptors() 无业务逻辑页面跳转 addViewControllers() 合而为一 sprin ...

  7. SpringBoot配置与应用 SpringBoot与(Spring和springmvc的区别)

    1.什么是springboot? springboot与springmvc的区别,springboot代替了springmvc? ssm包含了spring与springmvc还有mybatis. 用到 ...

  8. 超级详细!!!Spring、SpringMVC、Mybatis知识点完整版更新!IOD、DI依赖注入、Mybatis配置、SQL、MVC拦截器、Web开发、SSM整合案例。

    Spring Spring框架知识点完整版 上篇,SSM三部曲之一 知识点涵盖:Spring简介IOC控制反转DI依赖注入LombokSPEL配置文件低频知识点注解开发Spring常用注解 链接:ht ...

  9. Spring中开启组件扫描细节配置

    <!--示例 1 use-default-filters="false" 表示现在不使用默认 filter,自己配置 filter context:include-filte ...

最新文章

  1. Rust 1.30带来更多元编程支持,并改进了模块系统
  2. 软件Trimmomatic
  3. modulenotfounderror: no module 或modulenotfounderror: no module named 'matplotlib._path' 原因详解及解决办法
  4. MapReduce基础开发之五分布式下载ftp文件到本地再迁移到hdfs
  5. mysql8 2058_SQLyog连接MySQL8.0及以上版本出现2058错误解决方案
  6. 接软件开发项目,你需要知道这些!
  7. dj鲜生-26-登陆时-记住用户名的操作
  8. rocketMQ基本架构简介
  9. 余承东透露华为Mate X发布时间:今年六月上市
  10. 【Yarn】Yarn : 日志管理
  11. react build后直接从浏览器打开
  12. 设计模式-策略模式和模板方法模式
  13. 一个案例,看懂用户画像如何做出效益
  14. linux 系统重启过程,linux 系统启动流程
  15. Vue快速入门一:官网、下载、定义变量
  16. Veritas Flex 5150 实例管理-NetBackup实例创建
  17. DOS命令不需格式化U盘-FAT32轻松转换成NTFS
  18. 【深度域自适应】一、DANN与梯度反转层(GRL)详解
  19. #Paper Reading# Why Should I Trust You? Explaining the Predictions of Any Classifier
  20. java打印大风车的代码_自定义View之大风车系列demo(一)

热门文章

  1. Vs2008不能调试的问题
  2. 访问IIS元数据库失败解决方法(转)
  3. 动态创建DataTable[转]
  4. [Unity动画]04.Avatar Mask
  5. BZOJ4129: Haruna’s Breakfast
  6. adobe photoshop cc 复制css链接
  7. HTML 表格垂直对齐方式
  8. load-store/register-memory/register-plus-memory比较
  9. PowerDesigner教程系列(四)概念数据模型
  10. HTML标签strong和em