我需要从以下位置排除多种包模式:

@ComponentScan(
    basePackages = "com.data",
    excludeFilters = @ComponentScan.Filter(
        type = FilterType.REGEX,
        pattern = "package.*"
    )
)

我正在使用最新的 Spring 靴。

最佳答案

excludeFilters 接受一个数组

@ComponentScan(
    basePackages = "com.example",
    excludeFilters = {
        @ComponentScan.Filter(...),
        @ComponentScan.Filter(...),
        @ComponentScan.Filter(...),
    }
)

关于spring-boot - Spring 的 @ComponentScan excludeFilters 多个过滤器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50230507/

10-11 18:20