发布到线上的包结构

runtime是发布到线上的目录结构



1.项目pom.xml添加打包配置

<build>
<plugins> <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>sigma.resource.sync.SigmaApplication</mainClass>
<layout>JAR</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<useDefaultDelimiters>true</useDefaultDelimiters><!-- 这是重点-->
</configuration>
<executions>
<execution>
<id>copy-fatjar</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/build</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.${project.packaging}</include>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-bin</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/build/bin</outputDirectory>
<resources>
<resource>
<directory>src/main/bin</directory>
<include>start.sh</include>
<include>stop.sh</include>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy resource</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${basedir}/src/main</directory>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin> <plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>src/main/resources/public</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins> <resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources> </build>

2.创建脚本目录

src/main/bin

3.启动及停止脚本

src/main/bin/start.sh

#!/bin/bash

#----------以下变量可以在脚本中直接使用----------------
# $def_app_id 应用id
# $def_app_name 应用名称
# $def_app_domain 应用域名
# $def_app_deploy_path 兼容老部署,废弃
# $def_path_app_log 应用日志路径 如:/export/Logs/
# $def_path_app_data 如:/export/Data
# $def_group_id 分组 id
# $def_instance_id 实例id
# $def_instance_name 实例名称 server1
# $def_instance_path 实例完成路径 /export/Instances/jone/server1/
# $def_host_ip
#-------------------------- #set -o errexit
readonly APP_NAME="sigma-sync" #定义当前应用的名称
readonly JAR_VERSION="1.0-SNAPSHOT" #打包的JAR版本
#获取当前应用的进程 id
function get_pid
{
pgrep -f "$EXE_JAR"
} BASEDIR=$(cd $(dirname $0) && pwd)/.. # 获取运行脚本的上级目录 readonly JAVA_HOME="/export/servers/jdk1.8.0_60" # java home
readonly JAVA="$JAVA_HOME/bin/java"
APP_LOG_DIR="/export/Logs/sigma-sync"
mkdir -p ${APP_LOG_DIR}
EXE_JAR="$APP_NAME-$JAR_VERSION.jar"
echo "$EXE_JAR"
# FIXME: make this configurable
OPTS_MEMORY="-Xms2G -Xmx2G -server -XX:MaxPermSize=256M -Xss256K" #定义启动 jvm 的参数信息。
CLASSPATH="$BASEDIR/" [[ -z $(get_pid) ]] || {
echo "ERROR: $APP_NAME already running" >&2
exit 1
} echo "Starting $APP_NAME ...."
[[ -x $JAVA ]] || {
echo "ERROR: no executable java found at $JAVA" >&2
exit 1
}
cd $BASEDIR
setsid "$JAVA" $OPTS_MEMORY -jar "$EXE_JAR" "$@" > /dev/null 2>&1 & sleep 0.5
[[ -n $(get_pid) ]] || {
echo "ERROR: $APP_NAME failed to start" >&2
exit 1
} echo "$APP_NAME is up runnig :)"

src/main/bin/stop.sh

#!/bin/bash

set -o errexit
set -o nounset readonly APP_NAME="sigma-sync" #定义当前应用的名称
readonly JAR_VERSION="1.0-SNAPSHOT" #打包的JAR版本
EXE_JAR="$APP_NAME-$JAR_VERSION.jar"
#获取当前应用的进程 id
function get_running_pid
{
pgrep -f "$EXE_JAR"
} readonly SELF_DIR=$(cd $(dirname $0) && pwd) function stop
{
local -i timeout=20
local -i interval=1
local -r service_pid=$(get_running_pid) || true # ignore error
[[ -n $service_pid ]] || {
echo "WARNING: process not found, nothing to stop" >&2
exit 0
}
kill $service_pid
while (( timeout > 0 )) && get_running_pid > /dev/null; do
echo -n "."ƒ
sleep $interval
timeout=$(( timeout - interval ))
done
if get_running_pid > /dev/null; then
echo "WARNING: process still alive, sending SIGKILL ..." >&2
kill -9 "$service_pid"
fi
}
function main
{
get_running_pid > /dev/null || {
echo "WARNING: process not found, nothing to stop" >&2
exit 0 # Ignore error
}
stop
}
main "$@"

4.构建

mvn clean -U install -P prod -Dmaven.test.skip=true

springboot打包上线的更多相关文章

  1. springBoot 打包上线跳过连接数据库

    在pom文件下添加 <skipTests>true</skipTests> 这一行 如下: <properties> <project.build.sourc ...

  2. Xcode 8 打包上线 iTunes Connect 找不到构建版本

    Xcode 8 打包上线 iTunes Connect 找不到构建版本 最近苹果推出新的mac操作系统(macOS Sierra 10.12),大家可能都已经升级了,作为一个开发者,小编肯定是第一时间 ...

  3. springboot 打包

    springboot 打包 先clean 然后 maven package 通过命令java -jar target/GoshenWepPro-0.1.0.jar运行程序

  4. Vuejs技术栈从CLI到打包上线实战全解析

    前言 本文是自己vue项目实践中的一些总结,针对Vue2及相关技术栈,实践中版本为2.3.3. 开发前须知 vue-cli 在开发前,我们要至少通读一遍vue官方文档和API(看官方文档是最重要的,胜 ...

  5. 前端自动化(三) 合并压缩css、压缩js、添加时间戳、打包上线操作

    前端自动化(三)   合并压缩css.压缩js.添加时间戳.打包上线操作 此文在前两篇基础上对比参考,会很方便理解 gulp.task("delete",function(){ r ...

  6. springboot打包不同环境配置与shell脚本部署

    本篇和大家分享的是springboot打包并结合shell脚本命令部署,重点在分享一个shell程序启动工具,希望能便利工作: profiles指定不同环境的配置 maven-assembly-plu ...

  7. SpringBoot打包成war

    关于SpringBoot打成jar包以及jar包如何在Linux持久运行,我在前面已经说过了,所以本次不再赘述. 关于SpringBoot打包成war,其实步骤特别简单,如下图所示(如果是jar,通常 ...

  8. vue菜鸟从业记:完成项目最后一公里之真机测试和打包上线

    最近我朋友王小闰他们公司的项目开发已经进入收尾阶段,前后端并行开发的差不多了,联调也调过了,上篇文章里也讲到了,所谓联调,就仿佛在说“我也不知道我的接口文档写的对不对,我们验证一下吧?我也不知道我的数 ...

  9. springboot打包去除资源文件,启动时指定配置文件位置,使用log4j2替换默认logback

    springboot打包时,去掉资源文件 <build> <resources> <resource> <directory>src/main/reso ...

随机推荐

  1. 996. Number of Squareful Arrays

    Given an array A of non-negative integers, the array is squareful if for every pair of adjacent elem ...

  2. php的call_user_func_array()使用场景

    1..动态调用普通函数时,比如参数和调用方法名称不确定的时候很好用 function sayEnglish($fName, $content) { echo 'I am ' . $content; } ...

  3. dedecms arclist分页

    https://blog.csdn.net/qq_41104911/article/details/81510589

  4. hdu4499 搜索

    题意:       给你一个棋盘,最大是5*5的,问你最多可以放多少个炮,炮和炮之间不可以相互攻击,这块只的是只能走一步,不存在两个炮中间三个棋子的情况.. 思路:    刚开始想的是把所有的空位置都 ...

  5. POJ1719行列匹配

    题意:      给一个n*m的格子,每一列都有两个白色的,其余的全是黑色的,然后要选择m个格子,要求是每一列必须也只能选一个,而每一行至少选择一个,输出一种可行的方案没,输出的格式是输出m个数,表示 ...

  6. Win64 驱动内核编程-1.环境搭建

    驱动开发环境及其双机调试环境搭建 开发环境搭建 使用工具:vs2015,Windows 10 SDK_10.0.14393,WDK10.0.14393.0 (1)安装VS2015  随便一个版本吧,我 ...

  7. WindowsPE 第七章 资源表

    资源表 在程序设计中,总会设计一些数据.这些数据可能是源代码内部需要用到的常量,菜单选项.界面描述等:也可能是源代码外部的,比如程序的图标文件.北京音乐文件.配置文件等,以上这些数据统称为资源.按照程 ...

  8. 本地计算机上的Apple Mobile Device服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止

    解决办法:1.开始--运行--regedit.exe,打开注册表编辑器,删除以下两个键: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Wi ...

  9. C++ primer plus读书笔记——第3章 处理数据

    第3章 处理数据 1. C++对于变量名称的长度没有限制,ANSI C只保证名称中的前63个字符有意义(前63个字符相同的名称被认为是相同的,即使第64个字符不同). 2. 对类型名(int)使用si ...

  10. oo——第三单元总结

    前言 第三单元是我们学习oo以来第一次接触JML.这一单元的三次作业和以前一样,采用了难度递进的方式,而且前一次作业的设计思路在下一次作业都多多少少有些体现(或者说是在其基础上做出的改进).而且本单元 ...