spring boot 打包和部署
2017-04-19 09:58
471 查看
这两天项目刚刚写完准备测试,项目是用Springboot搭建的,一个project和三个module,分别是API(用来其他系统的调用,包括前端)、service(内含service层、dao层和mapper以及mybatis的xml文件)和job(任务调度的module),其中API依赖service和job。在父类和API中添加如下的启动项,而在父类中不用处理,因为这是在API中进行的打包操作:
运行在idea的控制台运行mvn clean package Ptest这个mvn命令,打包test环境的配置文件,将项目打成jar包。
jar包打包完成后将jar包上传到Linux的系统坏境,写一个启动脚本,运行下边的脚本就可以将项目启动:
&符号的意思是程序在后台运行,nohup是不挂断的运行命令,这样就可以保证程序运行的时候始终保持。需要注意的是,将脚本文件在文本中编辑后上传到Linux中后,运行时会出现以下这两个错误:
这是由于格式不合符要求导致的,因此要设置格式,设置格式的命令如下:
下边是stop.sh脚本:
<build> <plugins> <!--提供mvn命令直接运行springboot--> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <excludes> <exclude>application.properties</exclude> <exclude>application-dev.properties</exclude> <exclude>application-online.properties</exclude> <exclude>application-test.properties</exclude> <exclude>logback-spring.xml</exclude> </excludes> </resource> <resource> <filtering>true</filtering> <directory>src/main/resources</directory> <includes> <include>application.properties</include> <include>application-${profileActive}.properties</include> <include>logback-spring.xml</include> </includes> </resource> </resources> </build>
运行在idea的控制台运行mvn clean package Ptest这个mvn命令,打包test环境的配置文件,将项目打成jar包。
jar包打包完成后将jar包上传到Linux的系统坏境,写一个启动脚本,运行下边的脚本就可以将项目启动:
#!/bin/bash nohup java -jar yourapp.jar & echo Asset is already started!
&符号的意思是程序在后台运行,nohup是不挂断的运行命令,这样就可以保证程序运行的时候始终保持。需要注意的是,将脚本文件在文本中编辑后上传到Linux中后,运行时会出现以下这两个错误:
stop.sh: line 11: syntax error: unexpected end of file : command not found
这是由于格式不合符要求导致的,因此要设置格式,设置格式的命令如下:
vi start.sh :set fileformat=unix :wq
下边是stop.sh脚本:
#!/bin/bash PID=$(ps -ef | grep yourappp.jar | grep -v grep | awk '{ print $2 }') if [ -z "$PID" ] then echo Asset is already stopped! else echo kill $PID kill $PID echo Asset stopped! fi
相关文章推荐
- SpringBoot热部署与打包
- springboot(十二):springboot如何测试打包部署
- SpringBoot 打包成war包,部署到tomcat
- springboot如何测试打包部署
- springboot程序打包部署
- springboot打包docker镜像部署
- Spring Boot 打包部署
- Spring boot(4)-应用打包部署
- springboot项目的打包部署(gralde和maven)
- SpringBoot学习笔记之打包部署
- [置顶] 一步一步学springboot (五)打包成标准的web工程war包可独立部署到tomcat或weblogic
- SpringBoot之打包成war包部署到tomcat
- 【Springboot】 学习一 应用打包部署
- spring boot打包 部署 依赖 hc/info
- Spring boot(4)-应用打包部署
- springboot(十二):springboot如何测试打包部署
- springboot 打包部署 共享依赖包(分布式开发集中式部署微服务)
- springboot 打包部署 共享依赖包(分布式开发集中式部署微服务)
- [置顶] Eclipse新建Spring-boot项目,打包部署并输出HelloWord
- springboot项目的打包部署(gralde和maven)