@SpringBootApplication
Each Spring boot project has an entry class named *application that has a main method in the entry class . used in the Main method:
Springapplication.run (Demoapplication.class, args);
Start the spring boot app.
Above is the source of @springbootapplication
You can tell that @springbootapplication is a combination of annotations that mainly combine the following annotations
- @SpringBootConfiguration: This is a configuration note for the Spring Boot project, and it is recommended to use @ springbootconfiguration instead of @configuration in the Spring boot project
- @EnableAutoConfiguration: Enable automatic configuration, which causes spring boot to automatically configure item configuration items based on the jar packages that are dependent on the project
- @ComponentScan: The default scan @springbootapplication the class's sibling directory and its subdirectories
To turn off specific automatic configurations
Use @springbootapplication's exclude parameter, for example:@SpringBootApplication (exclude = {Redisautoconfiguration.class})
Starter Pom
Spring boot improves the starter pom to simplify the development of most scenarios, so long as the starter pom required for the application is used, the associated configuration can be dispensed with, and the automatically configured beans provided by spring boot are available
Use XML in special cases
Although spring boot can implement XML-free, there are special cases where you need to use an XML configuration file. You can use @importresource to load the XML configuration file at this time. Example:@ImportResource ({"Classpath:some.xml", "Classpath:other.xml"})
Spring Boot Learning (iv)