The core of Spring boot

Source: Internet
Author: User

Ingress classes and @springbootapplication

Spring boot projects typically have *application entry classes, and the entry class will have the main method, which is the entry method for a standard Java application.

@SpringBootApplication annotations are the core annotations of spring boot, which is actually a combination of annotations:

The annotations are mainly composed of the following annotations:

@SpringBootConfiguration: This is the configuration note for the Spring Boot project, which is also a combined annotation. Recommended @ springbootconfiguration instead of @configuration in spring Boot project

@EnableAutoConfiguration: Enable automatic configuration, which causes spring boot to automatically configure the project's configuration items based on the jar packages that are dependent on the project: for example: We have added spring-boot-starter-web dependencies, The project will also introduce SPRINGMVC dependencies, and Spring boot will automatically configure Tomcat and SPRINGMVC

@ComponentScan: The default scan @springbootapplication is the same as the sibling of the class and its subdirectories.

Turn off automatic configuration

Through the above, we learned that spring boot will be automatically configured based on the jar package dependencies in the project, and spring boot supports automatic configuration as follows (very many):

If we don't need spring boot auto-configuration and want to turn off automatic configuration for an item, how do I set it up?

For example: We do not want to configure Redis automatically and want to configure it manually.

Of course, the rest of the configuration is similar.

Custom Banner

http://www.network-science.de/ascii/

Global configuration file

The Spring Boot Project uses a global configuration file, Application.properties or APPLICATION.YML, under the Resources directory or under the classpath/config, generally we put it under resources.

Modify the Tomcat port to 8088

Restart the app to see the effect:

The core of Spring boot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.