@ComponentScan(excludeFilters =
@ComponentScan.Filter(type = FilterType.REGEX,pattern = "com.action.other.*")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
根据FilterType不同有不同的过滤方式,这里是根据正则过滤
@SpringBootApplication@ComponentScan(excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX,pattern = "com.action.other.*") })public class Application { public static void ma...
@ComponentScan(excludeFilters =
@ComponentScan.Filter(type = FilterType.REGEX,pattern = "com.integration.aop.log.service.*")
文章目录前因方式一方式二方式三方式四方式五方式六总结
我们都知道component-scan在springmvc或者
springboot
中可以
扫描
包
路径,但是我们如何使用里面的属性
排除
不需要
扫描
的类?
使用spring的xml配置方式实现,这个是基本功,知道这种方式,那么注解方式就容易理解了
<!-- 定义项目
扫描
包
的路径,并且
排除
ApplicationContextConfig和WebSpringMVCServletConfig-->
<context:component-
SpringBoot
Application
话不多说,先写三遍:
SpringBoot
Application、
SpringBoot
Application、
SpringBoot
Application
我们先来看看
SpringBoot
Application里面是啥
1.Target
这是个啥? 它是用于设定注解范围(被描述的注解可以用在什么地方)也急速hi限制了注解的作用域,那啥是注解的范围?注解的范围又有哪些呢?
@Target说明了Annotation所修饰的对象范围:Annotation可被.
搭建
springboot
项目要用到的
springboot
的一些jar
包
(spring-boot,spring-boot-actuator,spring-boot-actuator-autoconfigure,spring-boot-autoconfigure,spring-boot-configuration-processor,spring-boot-dependencies,spring-boot-devtools,spring-boot-loader-tools,spring-boot-parent,spring-boot-starter-*,spring-boot-test,spring-boot-tools)
4. 依赖
包
没有被正确
扫描
检查application class的
扫描
路径是否
包
含所有的依赖
包
。可以在application.properties或application.yml中设置
扫描
路径。
综上所述,如果
springboot
扫描
不到依赖
包
,可能是由于依赖
包
未正确添加、依赖
包
版本不匹配、依赖
包
与
springboot
不兼容、依赖
包
没有被正确
扫描
等原因导致的。可以根据具体情况分析并解决。