0. Pre-knowledge
The projects packaged by springboot are divided into two types jar
: andwar
jar package
When a jar type project is packaged with the SpringBoot packaging plug-in, a tomcat jar will be built
So we can use jdk to run directly, and put the function code into its built-in tomcat to run.
war package
When packaging, you need to delete the built-in tomcat plug-in and configure the dependencies of the servlet. Just put the war in the tomcat server and run it normally. 1. Make jar package
1. Import the SpringBoot packaging plugin
pom.xml
Add the following code in the root directory of the project
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
After the copy is complete, choose to update maven dependencies
2. Check whether the packaging method is jar
If not, the default is
jar
package mode
If any, modify to jar
<packaging>jar</packaging>
3. Packing
Click Maven
–> Lifecycle
—> on the rightpackage
4. Successfully packaged
Look at the corresponding jar package location
5. Try running on the server
Switch to a location on the server where you want to store the backend jar package, and open the transfer via xftp
nohup java -jar springboot.jar &
nohup
: no hang up (do not hang up) and save the screen output record to the log file
&
: Indicates background startup
6. Try the browser to access the corresponding interface
Open implementation log
tail -f nohup.out
browser access page
Corresponding output log file
It doesn't matter here, we just test whether it is connected.
The interfaces for subsequent requests are all accessed through the front end