Home  >  Article  >  Java  >  How to package and deploy springboot to linux server

How to package and deploy springboot to linux server

WBOY
WBOYforward
2023-05-10 17:07:121089browse

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>

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()); 
 } 
}

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete