Today’s focus is on seven ways to start the Spring Boot project.
The first kind of
It is also the most common type of local boot
This is done by executing the main method to boot directly. And that’s how most of us start locally.
The second,
Jar the project and use the command
java -jar XXX.jar
You can also add various parameters after the day after this command. For example: specify port, set heap memory related parameters, multiple environment to specify an environment, etc.
The third kind of
A fourth
This approach is more flexible. For example, ComponentScan allows you to customize the package directory.
The fifth
Directory to boot, we can decompress the JAR
In the meta-INF directory there is a meta-INF/manifest.mf file, the contents of the manifest.mf file
The point here is that the start-class is our Application Class. There is also a main-class, which can be used to start a project in the package directory if the old project cannot be started using jar:
java org.springframework.boot.loader.JarLauncher
To launch our project.
6 kinds of
War package startup: There are two ways to switch from a JAR to a WAR package
1 species:
1. Modify or add war in pom. XML
2. Create a webapp/WEB-INF directory (as opposed to SRC /main)
3. Create an empty web.xml file
The second:
1. Modify or add war in pom. XML
2. Add the plug-in to the pom. XML file
Type into a WAR package, boot mode
java -jar demo.war
The 7th kind of
The principle is the same as the main method. Use the maven command;
mvn spring-boot:run