没有@SpringBootApplication,Spring boot应用程序如何工作?
在我们的项目中,我们使用了@Component、@Configuration以及带有@Bean注解的bean配置。稍后我们注释了 spring-boot-maven-plugin 依赖项和 @SpringBootApplication,但应用程序在没有 @SpringBootApplication 注解的情况下构建成功。我不明白它是如何工作的?
最佳答案
@SpringBootApplication注解是@ComponentScan、@Configuration和@EnableAutoConfiguration的组合。
如果您注释掉@SpringBootApplication,但仍然包含@Configuration和@Component,您仍然允许扫描您的应用程序以查找组件,并允许将其他组件添加到applicationContext。唯一的区别是Spring的自动配置机制不是包括。
关于java - 如果没有@SpringBootApplication,Spring boot应用程序如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56612527/