美文网首页
Springboot启动时排除一些不需要注入的组件

Springboot启动时排除一些不需要注入的组件

作者: fanderboy | 来源:发表于2021-02-27 23:45 被阅读0次

    1、@SpringBootApplication注解中的exclude只能排除自动配置的类,例如:

     @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
    

    2、@ComponentScan注解中的excludeFilters才是排除自定义配置类的正确方式,例如:

    @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {DefaultDruidConfig.class}))
    

    相关文章

      网友评论

          本文标题:Springboot启动时排除一些不需要注入的组件

          本文链接:https://www.haomeiwen.com/subject/uxywfltx.html