Will the introduction of a starter in SpringBoot load all AutoConfig classes into the container?

when I introduce spring-boot-starter-web, I will introduce spring-boot-autoconfigure "s jar package. Spring is to scan the contents of the spring.factories file under the META-INF of all jar packages under the project and then add the automatic configuration class to the container, so whether all the automatic configuration classes will be added to the container? if so, will it be wasteful? if not where the loading place is selected. Mengxin asked the boss for an explanation.

Jul.30,2021

you can choose to exclude classes that you do not want to configure automatically, by annotating or configuring properties

@Configuration
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class MyConfiguration {
}

or exclude configuration classes that you do not want to load through the spring.autoconfigure.exclude attribute in the configuration file.


well, thank you for your answer. I have learned this method of exclusion. I am still a little confused that any starter will introduce all the automatic configuration classes of spring-boot-autoconfigure and load them into the spring container. For example, only the starter of web will load the automatic configuration classes of SpringCloud under spring-boot-autoconfigure, right? am I right? or when SpringBoot loads the classes of these configurations, starter, without SpringCloud will not load the automatic configuration of SpringCloud into the Spring container.

Menu