What is @SpringBootApplication annotation in spring boot?
Many Spring Boot developers always have their main class annotated with @Configuration, @EnableAutoConfiguration and
@ComponentScan. Since these annotations are so frequently used together (especially if you follow the best practices above),
Spring Boot provides a convenient @SpringBootApplication alternative.
The @SpringBootApplication annotation is equivalent to using @Configuration, @EnableAutoConfiguration and @ComponentScan
with their default attributes:
package com.java2novice.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootWebApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootWebApplication.class, args);
}
}
|
The following are the parameters accepted in the @SpringBootApplication annotation:
exclude: Exclude the list of classes from the auto configuration.
excludeNames: Exclude the list of fully qualified class names from the auto configuration. This parameter added since spring boot 1.3.0.
scanBasePackageClasses: Provide the list of classes that has to be applied for the @ComponentScan.
scanBasePackages Provide the list of packages that has to be applied for the @ComponentScan. This parameter added since spring boot 1.3.0.
|