简体   繁体   中英

How does Spring boot application works without @SpringBootApplication?

How does Spring boot application works without @SpringBootApplication?

In our project, we used @Component, @Configuration and bean configuration with @Bean annotation. Later we have commented both the spring-boot-maven-plugin dependency and @SpringBootApplication, but application is built successfully without @SpringBootApplication annotation. I don't understand how its working?

@SpringBootApplication annotation is a combination of @ComponentScan, @Configuration and @EnableAutoConfiguration.

If you comment out @SpringBootApplication but still include @Configuration and @Component you are still allowing your application to be scanned for components and allowing additional components to be added to the applicationContext.The only difference is that Spring's auto configuration mechanism is not included.

https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-using-springbootapplication-annotation.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM