Springboot项目打jar包流程
1、在POM中确定MAVEN打包插件已经引入
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
2、点击MAVEN中的clean清理项目
3、点击package进行项目打jar包
4、打包好的jar包存放在target目录下,例如XXX.jar
5、将jar包上传到centos7中,并且执行命令 nohup java -jar XXX.jar & 进行项目后台启动
Springboot项目打war包流程
1、在POM文件中确定MAVEN打包插件已经引入
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
2、在POM文件中去掉Springboot自带的tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
3、在POM文件中声明项目打包方式为war包
<packaging>war</packaging>
4、在POM文件中导入war包依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
5、修改启动类文件
修改前
@SpringBootApplication @MapperScan("com.qf.sclg.dao") @EnableTransactionManagement public class SclgApplication{ public static void main(String[] args) { SpringApplication.run(SclgApplication.class, args); } }
修改后
@SpringBootApplication @MapperScan("com.qf.sclg.dao") @EnableTransactionManagement public class SclgApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(SclgApplication.class, args); } @Override public SpringApplicationBuilder createSpringApplicationBuilder() { return new SpringApplicationBuilder(SclgApplication.class); } }
6、点击MAVEN中的clean清理项目
7、点击install进行项目打war包
8、打包好的jar包存放在target目录下,例如XXX.war
9、将打好的war包添加到tomcat的webapps目录下,启动的时候记得在项目路径上添加war包的名称 标签:Springboot,jar,boot,war,public,SclgApplication From: https://www.cnblogs.com/l1pe1/p/16780192.html