美文网首页程序员springboot
以jar文件部署springboot构建的web应用

以jar文件部署springboot构建的web应用

作者: codewang | 来源:发表于2017-04-28 14:43 被阅读0次

1、在STS中项目右键,以springboot的maven插件(spring-boot-maven-plugin)进行打包


2.在下图项目路径下招到打包成功的jar包,这就是我们部署的文件

一、无外部配置文件运行

1、将jar包上传至安装了java环境的centos上
在当前jar包的目录下运行命令 **java -jar firstproject-0.0.1-SNAPSHOT.jar **

二、有外部配置文件运行,这种部署可以灵活的更改配置文件

1、修改application.yml中的端口和context-path

server:
   port: 10000  
   context-path: /mydemo

2、将jar包和application.yml上传至安装了java环境的centos上


在当前jar包的目录下运行命令 **java -jar -Dspring.config.location=/study/application.yml firstproject-0.0.1-SNAPSHOT.jar ** ,其中参数 spring.config.location=配置文件的位置

相关文章

网友评论

    本文标题:以jar文件部署springboot构建的web应用

    本文链接:https://www.haomeiwen.com/subject/hcbozttx.html