tomcat - @EnableAutoConfiguration - excludeName

标签 tomcat spring-boot

我正在开发一个 Springboot 应用程序,其中服务器启动 (Tomcat) 会初始化一堆类。有一些不需要的正在初始化,我正在尝试提高启动性能,所以不想初始化这些类。我尝试在带有 excludeName 参数的 SpringBootServletInitializer 中使用 @EnableAutoConfiguration 注释,如下所示:

@EnableAutoConfiguration(excludeName  = "com.foler.subfolder.ExampleClass")

我还尝试了另一个参数 @EnableAutoConfiguration(exclude = ExampelClass.class)

最佳答案

There are some unwanted ones being initialized and I am trying to improve the performance of startup so don't want to initialize these classes.

自动配置(使用 @EnableAutoConfiguration )总是在用户定义的 bean 注册后应用,看 here在同一点上来自此处的 API。

所以,你实际上应该使用 @ComponentScan 过滤类作为扫描的一部分,这样容器可能会加速(因为它不会在容器启动期间从排除的包/类创建 bean 对象)。

@ComponentScan(basePackages = {"com.foler"}, 
        excludeFilters = @ComponentScan.Filter(
                           type=FilterType.ASSIGNABLE_TYPE,
                           value = ExampelClass.class))

Is there any way I can add two or more classes for value parameter?

values接受类型 Class[] array ,因此您可以将多个类设置为 value = {ExampelClass1.class, ExampelClass2.class}

关于tomcat - @EnableAutoConfiguration - excludeName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43312892/

相关文章:

java - 登录时,我的 Apache Tomcat webapp 转到 webapp/favicon.ico,我怎样才能阻止我的 webapp 重定向到这个?

java - Tomcat 6.0 和 7.0 在 Eclipse Luna 上启动失败

java - Tomcat 在我的项目中显示类的 NoClassDefFoundError

Spring security antMatcher 没有按预期工作

java - 由 : org. 引起 postgresql.util.PSQLException: ERROR: type "enum"does not exist

java - 是否可以在 tomcat 中编辑类文件并重新编译该单个文件?

tomcat - 真正的HttpSession类在哪里?

java - Tomcat 中的 Quartz 调度程序内存泄漏

java - 如何为空值注册 Spring 转换器?

java - 如何正确使用Java中Apollo客户端的RxJava2库进行同步调用?