pom文件指定jar包格式:

pom文件指定主类:

在启动类加上 extends SpringBootServletInitializer 并重写 configure 方法,这是为了打包 spring boot 项目:
@MapperScan("xxx.xxx.mapper")
@SpringBootApplication(scanBasePackages = {"xxx.xxx"})
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
/**
* 为了打包springBoot项目
*
* @param builder SpringApplicationBuilder
* @return SpringApplicationBuilder
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(this.getClass());
}
}
打jar包:

生成jar包所在位置:

最后上传到服务器。
简单的部署,退出控制台即失效:
放置jar包的目录下输入: java -jar xxx-1.0-SNAPSHOT.jar 即可。
后台运行:
nohup java -jar xxx-1.0-SNAPSHOT.jar &
启动后在当前目录生成一个nohup.out文件
查看启动后的服务:
ps -ef|grep java

关闭服务:
kill -9 27697
网友评论