I'm having some difficulty preventing Spring Boot from auto configuring some classes (in this example: SolrAutoConfiguration). To illustrate I've setup a much reduced example:
https://github.com/timtebeek/componentscan-exclusions
In reality there's some 20+ internal @SpringBootApplication
projects, each with their own dependencies coming together. (Not ideal / not my idea, but hard to move away from now.)
The problem arises because multiple subprojects are using Solr 5.2.1, but Spring Boot is only compatible with 4.x. In the final application (module-b in the example) I want to import all @SpringBootApplication
classes across all my modules, while preventing SolrAutoConfiguration
from running:
@ComponentScan("project") // Broad scan across all company jars
@SpringBootApplication(exclude = { SolrAutoConfiguration.class }) // Failing exclude
public class ModuleBApp {
public static void main(final String[] args) {
SpringApplication.run(ModuleBApp.class, args);
}
}
This fails, because any instance of @SpringBootApplication
picked up through the @ComponentScan
without the specific exclude, still loads SolrAutoConfiguration
.
What can I do to properly exclude a auto configuration class when combining multiple @SpringBootApplication
classes?
I've already tried to work with excludeFilters
on my final @SpringBootApplication
, but that hasn't yet lead to a solution.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…