Home > Java > javaTutorial > body text

How to package and deploy springboot to linux server

WBOY
Release: 2023-05-10 17:07:12
forward
1091 people have browsed it

1. Since springboot integrates tomcat, you no longer use war when packaging, but use jar

<groupid>cn</groupid> 
 <artifactid>back</artifactid> 
 <version>0.0.1-SNAPSHOT</version> 
<packaging>jar</packaging>
Copy after login

2. Add the springboot startup class to inherit SpringBootServletInitializer, and rewrite the configure method

public class BackApplication extends SpringBootServletInitializer{ 
 public static void main(String[] args) { 
  SpringApplication.run(BackApplication.class, args); 
 } 
 @Override//为了打包springboot项目 
 protected SpringApplicationBuilder configure( 
   SpringApplicationBuilder builder) { 
  return builder.sources(this.getClass()); 
 } 
}
Copy after login

3. Select the project, right-click and select Run As==>maven clean to clear the previous jar

4. Select the project, right-click and select Run As==>maven install to install Packaging

5. Copy the jar package from the target folder in the project to get the package you want

How to package and deploy springboot to linux server

6. Upload the jar to the service Period, (jdk must be installed and the corresponding port is open)

7. Enter the folder directory and execute the command nohup java -jar fx2Back.jar & Use nohup to start without hanging up, and then you can access page.

How to package and deploy springboot to linux server

#8. If you want to shut down the service, you can directly query the process number of the service and then kill.

How to package and deploy springboot to linux server

The above is the detailed content of How to package and deploy springboot to linux server. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template