第一步:添加插件

<plugins>
     <plugin>
         <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-maven-plugin</artifactId>
           <configuration>
                    <executable>true</executable>
                    <mainClass>com.bootdo.BootdoApplication</mainClass>
           </configuration>
     </plugin>
</plugins>
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.

部署springboot项目_java

第二步:启动程序类继承SpringBootServletInitializer,并重写configure方法

部署springboot项目_服务器_02

配置文件中需要指定好端口

部署springboot项目_java_03

第三步:我通过idea进行打包,利用maven插件

部署springboot项目_java_04

第四步:将打的jar包上传至服务器,jar包在target目录

文件上传方法见另一篇博客

第五步:服务器执行命令 

java -jar test.jar:缺点是控制台关闭后,程序终止。

nohup java -jar test.jar &:后台运行程序。

nohup java -jar test.jar >temp.txt &:指定程序日志打印的地方为temp.txt.可能会有错误

nohup: ignoring input and redirecting stderr to stdout
  • 1.

解决办法:nohup java -jar test.jar 2>temp.txt &

ok!浏览器测试请求:ip:端口号