spring boot 打包和部署
来源:互联网 发布:淘宝童装促销文案 编辑:程序博客网 时间:2024/05/17 03:59
这两天项目刚刚写完准备测试,项目是用Springboot搭建的,一个project和三个module,分别是API(用来其他系统的调用,包括前端)、service(内含service层、dao层和mapper以及mybatis的xml文件)和job(任务调度的module),其中API依赖service和job。在父类和API中添加如下的启动项,而在父类中不用处理,因为这是在API中进行的打包操作:
<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/bashnohup 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/bashPID=$(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 $PIDecho Asset stopped!fi
1 0
- spring boot 打包和部署
- Spring Boot 打包部署
- Spring boot打包部署
- spring boot 打包部署发布
- spring boot打包部署问题解决
- Spring Boot (十):打包部署
- Spring boot-应用打包部署
- Spring boot(4)-应用打包部署
- spring boot 打包及部署方式
- Spring boot(4)-应用打包部署
- spring boot打包 部署 依赖 hc/info
- Spring Boot打包war jar 部署tomcat
- Spring boot打包war、jar部署tomcat
- 如何将Spring Boot项目打包部署到外部Tomca
- Eclipse新建Spring-boot项目,打包部署并输出HelloWord
- 转载:Spring Boot (十二):springboot如何测试打包部署
- (spring boot)maven 打包war 部署到tomcat
- Spring boot程序的打包和启动
- ORA-01861: 文字与格式字符串不匹配
- hashmap根据value排序
- ActiveMQ有支持两种事务
- 重启网卡的几种方法
- CorelDRAW中如何复制对象属性详解
- spring boot 打包和部署
- 最长递增子序列 O(NlogN)算法,mark数组。ZOJ Problem Set
- 并查集—HDU 1213
- 必测的支付漏洞(一)使用fiddler篡改支付金额
- JSP三大指令元素
- amq的queue同步和异步接收消息
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element
- HTTP 协议漫谈
- python time、datetime模块学习使用