This is the 8th day of my participation in the August More Text Challenge
SpringBoot, as an integrated framework, is essentially a Spring project. The difference is that On the basis of traditional Spring, SpringBoot provides tedious configuration operations in a convention way, and provides a large number of out-of-the-box module dependencies to meet the integration between components. Achieve efficient development and easy maintenance of projects.
The characteristics of SprtingBoot
Provides a lot of automatic configuration
SpringBoot provides a large number of default configurations, which require more conventions than configurations. Developing projects based on default SpringBoot conventions greatly saves the configuration time. Of course, you can modify the default configurations through configuration files during development.
Starting using starter simplifies Maven configuration
SpringBoot provides starter dependencies corresponding to different framework components. When importing other components, you only need to import related starter dependencies in Maven coordinates.
Embedded Servvlet containers
Tomcat and Jetty containers are embedded in SpringBoot, and the project Jar package is packaged. You can directly run the java-jar springboot. Jar command to start the project.
No XML configuration is required
No XML configuration files are required in SpringBoot to implement the Spring configuration pattern
Actuator
SpringBoot provides the monitoring function of the Actuator, which can monitor the internal operation of programs and observe information such as Bean loading, environment variables and logs.
Initialize the SpringBoot project
We use the IDEA compiler to quickly build a SpringBoot project, which requires a local JDK environment.
- First create a new project in IDEA and selectSpring Initializr, select the local JDK environment, and click Next
- To set the project name, selectMaven ProjectAnd the correct Java version, click Next
- In order to quickly build a Web application, we addSpring WebLaunch the dependency and click Next
- Confirm the project name and location and click Finish. IDEA will automatically initialize SpringBoot project
- We can look at the pom.xml file in the root directory of the project and see the dependency information in the pom.xml file because we selected the Web starter dependency
- Finally, enter
main -> java -> com.example.springboot
In this directory, locate the SpringBootApplication file, right-click the current file, and run the SpringBoot project
Deploy the SpringBoot project
After successfully running the project in the IDEA compiler, it’s time to deploy the project locally outside the compiler and access the Web application through a browser.
- To make it more obvious how the project is accessed, create the HelloController controller and provide
/hello
Call the Hello method on the path that returns “Hello world!” . - Add the packaging configuration in pom.xml and package the SpringBoot project as a Jar package using the Maven command
- Open the command line at the project Jar package generation location and use
Java -jar xxx.jar
Command to execute the Jar package and run the Web project - Access it in a browserlocalhost:8080/helloHello world! The project is successfully deployed locally
Ok, so that’s our brief understanding of the SpringBoot framework, using IDEA to initialize the basic SpringBoot project and deploy the project Jar package locally. Over the next few days, we will gradually learn more about SpringBoot operations.