【发布时间】:2018-04-01 20:08:30
【问题描述】:
我正在尝试优化大型 Spring 4 Tomcat 应用程序。启动时间约为 2 分钟,我想知道是否有办法排除某些 jar 文件被扫描?例如,我不需要扫描 commons-lang b/c Spring 并不关心这一点,但是由于您在 applicationContext.xml 中基于 context:component-scan/base-package 定义扫描,所以我不太关心了解我该怎么做。有任何想法吗?也许对资源模式属性做点什么?
【问题讨论】:
-
AFAIK,spring 不扫描随机罐子。相关文档:docs.spring.io/spring/docs/current/spring-framework-reference/…
-
它怎么知道去哪里看呢?抱歉,我对此了解不多
-
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider 使用我认为和配置你告诉应该扫描什么包
-
如果您在 context:component-scan 中使用 use-default-filters="true" 会怎样?我们似乎在使用它并定义了大量的基础包
-
ClassPathScanningCandidateComponentProvider 无法知道某个 JAR 是否包含请求包中的类,因此它通过 java.net.URLClassLoader#findResources 扫描类路径中的所有 JAR。
标签: java optimization classpath spring-4 component-scan