How to exclude a BootstrapConfiguration class ?
How to exclude a BootstrapConfiguration class ?
For example, There is a class in the spring.factories like below: (B.T.W This file is in a jar file which is made by other team.)
org.springframework.cloud.bootstrap.BootstrapConfiguration=com.bd.FooConfiguration
But I DO NOT want to use this com.bd.FooConfiguration, How Could I exclude it ?
Dive into source code, I found that @BootstrapConfiguration has a exclude attribute.
org.springframework.cloud.bootstrap.BootstrapConfiguration
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface BootstrapConfiguration {
/**
* Excludes specific auto-configuration classes such that they will never be applied.
* @return classes to exclude
*/
Class<?>[] exclude() default {};
}
But when I use it like this:
@BootstrapConfiguration(exclude = {
com.bytedance.ea.cloud.tcc.TccConfigBootstrapConfiguration.class
})
@SpringBootApplication
public class Cloud_SpringBoot2ExampleApplication {
public static void main(String[] args) {
SpringApplication.run(Cloud_SpringBoot2ExampleApplication.class, args);
}
}
It never works. And I didn't find any usage or reference of the exclude attribute.

So I wonder:
- How to exclude a specific class?
- Is the
excludeattribute of@BootstrapConfigurationuseless ? Cause I Cannot find any reference of it.
up.
I'd like to override PropertySourceBootstrapConfiguration and use my CustomPropertySourceBootstrapConfiguration.
I need it to change priority between external application.properties, "in jar" application.properties and remote properties like this:
1. external application.properties
2. remote properties
3. application.properties from the JAR (classpath)
So, I've added CustomPropertySourceBootstrapConfiguration to BootstrapConfiguration in spring.factories and now I can't to exclude original PropertySourceBootstrapConfiguration from start up process.