Many Spring Boot developers like their apps to use auto-configuration, component scan and be able to define extra configuration on their "application class". A single
@SpringBootApplicationannotation can be used to enable those three features, that is:
@EnableAutoConfiguration: enable Spring Boot’s auto-configuration mechanism
@ComponentScan: enable@Componentscan on the package where the application is located (see the best practices)
@SpringBootConfiguration: enable registration of extra beans in the context or the import of additional configuration classes. An alternative to Spring’s standard@Configurationthat aids configuration detection in your integration tests.
// Same as @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
3368

被折叠的 条评论
为什么被折叠?



