在springbootApplication启动类上加入注解

@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = XX.class))
public @interface ComponentScan {
.....................
/**
* Specifies which types are not eligible for component scanning.
* @see #resourcePattern
*/
Filter[] excludeFilters() default {}; .........................
/**
* Declares the type filter to be used as an {@linkplain ComponentScan#includeFilters
* include filter} or {@linkplain ComponentScan#excludeFilters exclude filter}.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({})
@interface Filter { /**
* The type of filter to use.
* <p>Default is {@link FilterType#ANNOTATION}.
* @see #classes
* @see #pattern
*/
FilterType type() default FilterType.ANNOTATION;
...........................
}
}

其中@ComponentScan 注解属性excludeFilters可以过滤多个类型的类的加载,其中有内部类,可以指定过滤的类型,上面是指定class文件进行过滤,也可以指定其他类型的

public enum FilterType {

    /**
* Filter candidates marked with a given annotation.
* @see org.springframework.core.type.filter.AnnotationTypeFilter
*/
ANNOTATION, /**
* Filter candidates assignable to a given type.
* @see org.springframework.core.type.filter.AssignableTypeFilter
*/
ASSIGNABLE_TYPE, /**
* Filter candidates matching a given AspectJ type pattern expression.
* @see org.springframework.core.type.filter.AspectJTypeFilter
*/
ASPECTJ, /**
* Filter candidates matching a given regex pattern.
* @see org.springframework.core.type.filter.RegexPatternTypeFilter
*/
REGEX, /** Filter candidates using a given custom
* {@link org.springframework.core.type.filter.TypeFilter} implementation.
*/
CUSTOM }

springboot启动时过滤不需要注入的类的更多相关文章

  1. SpringBoot启动时 提示没有主清单属性 MANIFEST

    SpringBoot启动时 提示没有主清单属性 MANIFEST <?xml version="1.0" encoding="UTF-8"?> &l ...

  2. springBoot启动时让方法自动执行的几种实现方式

    一.开篇名义 在springBoot中我们有时候需要让项目在启动时提前加载相应的数据或者执行某个方法,那么实现提前加载的方式有哪些呢?接下来我带领大家逐个解答 1.实现ServletContextAw ...

  3. 【问题解决:信息提示】SpringBoot启动时提示The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path

    问题描述 springboot程序在启动时提示信息 [2018-10-24 21:59:05.214] - 440 信息 [restartedMain] --- org.apache.catalina ...

  4. Spring boot采坑记--- 在启动时RequstMappingHandlerMapping无法找到部分contorller类文件的解决方案

    最近有一个心得需求,需要在一个现有的springboot项目中增加一些新的功能,于是就在controller文件包下面创建新的包和类文件,但是后端开发完之后,本地测试发现前端访问报404错误,第一反应 ...

  5. (28)SpringBoot启动时的Banner设置【从零开始学Spring Boot】

    对于使用过Spring Boot的开发者来说,程序启动的时候输出的由字符组成的Spring符号并不陌生.这个是Spring Boot为自己设计的Banner: 1.    .   ____       ...

  6. springboot启动时控制台不显示映射的URL

    背景 今天,第一次使用 2.2.0 版本的springboot,在访问接口时发现访问不到,于是在控制台进行 URL 搜索,发现并相关没有内容 原因 springboot版本差异,切换回 2.0.5.R ...

  7. springboot启动时执行任务CommandLineRunner

    # SpringBoot中CommandLineRunner的作用> 平常开发中有可能需要实现在项目启动后执行的功能,SpringBoot提供的一种简单的实现方案就是添加一个model并实现Co ...

  8. SpringBoot启动时的Banner设置

    Spring Boot程序启动的时候输出的由字符组成的Spring符号并不陌生.这个是Spring Boot为自己设计的Banner: 1. 第一种方式:修改的时候,进行设置,在Application ...

  9. springboot 启动时执行方法

    Springboot提供了两种“开机启动”某些方法的方式:ApplicationRunner和CommandLineRunner.下面简单介绍下ApplicationRunner 1.创建个Tests ...

随机推荐

  1. 【知识强化】第五章 输入/输出(I/O)管理 5.2 I/O核心子系统I

    学习I/O核心子系统相关的一系列功能. 设备独立性软件.设备驱动程序.中断处理程序这三层其实是属于操作系统的内核部分的,所以它们也称作“I/O核心子系统”,又可以简称为“I/O系统”.在考研当中我们需 ...

  2. HDU-6532 Chessboard 2019广东省省赛B题(费用流)

    比赛场上很容易想到是费用流,但是没有想到建图方法qwq,太弱了. 这里直接贴官方题解: 费用流.离散化坐标,每行用一个点表示,每列也用一个点表示.表示第i-1行的点向表示第i行的点连边,容量为第i行及 ...

  3. php自动生成不重复的id

    PHP uniqid()函数可用于生成不重复的唯一标识符,该函数基于微秒级当前时间戳.在高并发或者间隔时长极短(如循环代码)的情况下,会出现大量重复数据.即使使用了第二个参数,也会重复,最好的方案是结 ...

  4. Java高并发网络编程(三)NIO

    从Java 1.4开始,Java提供了新的非阻塞IO操作API,用意是替代Java IO和Java Networking相关的API. NIO中有三个核心组件: Buffer缓冲区 Channel通道 ...

  5. 【leetcode】949. Largest Time for Given Digits

    题目如下: Given an array of 4 digits, return the largest 24 hour time that can be made. The smallest 24 ...

  6. 「题解」:$Six$

    问题 A: Six 时间限制: 1 Sec  内存限制: 512 MB 题面 题面谢绝公开. 题解 来写一篇正经的题解. 每一个数对于答案的贡献与数本身无关,只与它包含了哪几个质因数有关. 所以考虑二 ...

  7. 【hihocoder 1554】最短的 Nore0061

    [链接]http://hihocoder.com/problemset/problem/1554 [题意] 中文题 [题解] DP; 设f[i][j][k]表示前i个字符,第一个串已经得到了前j个字符 ...

  8. Linux环境下安装PHP的memced扩展

    先下载libmemcached: wget  https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.t ...

  9. 使用Nodejs 的http-proxy 模块做代理服务器的尝试

    参考 : https://blog.csdn.net/zhihuoqian9683/article/details/78944482  (亲测可行) http://www.mizuiren.com/4 ...

  10. [NOIP]模拟17 题解

    A.入阵曲 部分分很肥,正解写得常数稍大就会和暴力一个分,考试的时候写什么自己考虑.(滑稽 部分分的循环边界手抖写错了-25 (原本暴力分中的10分都没了啊啊啊) 没写挂的话应该有75,其实就是二维前 ...