spring与springMVC配置扫描的问题
为什么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配置扫描的问题相关推荐
- 配置spring、SpringMVC,mybatis进行整合
springframwork的官网 spring-projects/spring-mvc-showcase https://github.com/spring-projects/spring-mvc- ...
- 第9步 spring 配置 springmvc配置
spring配置 有5个网址 springboot 再讲一遍 spring的学习最好的方法是运行 官方demo 学习它里面的配置 . 我们不可能一下子理解spring里面的源码 spri ...
- spring boot web开发------自定义springmvc配置
1.如何自定义springmvc配置 旧的springmvc配置文件 <?xml version="1.0" encoding="UTF-8"?> ...
- springMVC+Spring+mybatis整合配置版与注解版
springMVC+Spring+mybatis整合 , 使用配置版来完成: -----------------------------前端 1.创建web系统,导入jar包: spring的jar包 ...
- springmvc 配置和spring配置?
最近在接触mybatis,之间使用springmvc时,配置文件一直是,web.xml+XX-servlet.xml 的配置(xx为web.xml中servlet name名称). 为了整合mybat ...
- spring boot实现WebMvcConfigurer接口定制SpringMvc配置
文章目录 自定义静态资源映射 addResourceHandlers() 拦截器 addInterceptors() 无业务逻辑页面跳转 addViewControllers() 合而为一 sprin ...
- SpringBoot配置与应用 SpringBoot与(Spring和springmvc的区别)
1.什么是springboot? springboot与springmvc的区别,springboot代替了springmvc? ssm包含了spring与springmvc还有mybatis. 用到 ...
- 超级详细!!!Spring、SpringMVC、Mybatis知识点完整版更新!IOD、DI依赖注入、Mybatis配置、SQL、MVC拦截器、Web开发、SSM整合案例。
Spring Spring框架知识点完整版 上篇,SSM三部曲之一 知识点涵盖:Spring简介IOC控制反转DI依赖注入LombokSPEL配置文件低频知识点注解开发Spring常用注解 链接:ht ...
- Spring中开启组件扫描细节配置
<!--示例 1 use-default-filters="false" 表示现在不使用默认 filter,自己配置 filter context:include-filte ...
最新文章
- Rust 1.30带来更多元编程支持,并改进了模块系统
- 软件Trimmomatic
- modulenotfounderror: no module 或modulenotfounderror: no module named 'matplotlib._path' 原因详解及解决办法
- MapReduce基础开发之五分布式下载ftp文件到本地再迁移到hdfs
- mysql8 2058_SQLyog连接MySQL8.0及以上版本出现2058错误解决方案
- 接软件开发项目,你需要知道这些!
- dj鲜生-26-登陆时-记住用户名的操作
- rocketMQ基本架构简介
- 余承东透露华为Mate X发布时间:今年六月上市
- 【Yarn】Yarn : 日志管理
- react build后直接从浏览器打开
- 设计模式-策略模式和模板方法模式
- 一个案例,看懂用户画像如何做出效益
- linux 系统重启过程,linux 系统启动流程
- Vue快速入门一:官网、下载、定义变量
- Veritas Flex 5150 实例管理-NetBackup实例创建
- DOS命令不需格式化U盘-FAT32轻松转换成NTFS
- 【深度域自适应】一、DANN与梯度反转层(GRL)详解
- #Paper Reading# Why Should I Trust You? Explaining the Predictions of Any Classifier
- java打印大风车的代码_自定义View之大风车系列demo(一)