What is the difference between @EnableAutoConfiguration and @ComponengScan in Spring Boot?
世界只因有你
世界只因有你 2017-05-17 10:00:53
0
2
817

In the current new version of spring boot, @SpringBootApplication is equivalent to @Configuration, @ComponentScan, @EnableConfiguration. What is the difference between @EnableAutoConfiguration and @ComponengScan? Since @EnableAutoConfiguration can automatically scan all beans under the path, then @ComponentScan seems to be unnecessary?

世界只因有你
世界只因有你

reply all(2)
phpcn_u1582

1.@EnableAutoConfiguration is mainly used to enable automatic configuration by scanning jar packages and configuring classes in META-INF/spring.factories and custom components for the current package and sub-packages (that is, those managed by spring) )
2.@ComponengScan is used to configure custom components (that is, managed by spring). You can specify the base path or BaseClass

If the class to be loaded is not under @EnableAutoConfiguration, it will not be loaded, and @ComponentScan is a class under the spring-context package, which has existed for a long time and is used in <context:component-scan>

淡淡烟草味

@ComponentScan can scan the packages in the jars you imported

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!