注意事项
1. 去除不需要的 jar
开发工具 jar :springs-boot-devtools
2. 监控一定要做好权限制或者去除
控制 jar :spring-boot-starter-actuator 监控
druid 的监控
swagger的接口
3 打包的时候要跳过测试
maven : clean package -Dmaven.test.skip=true
打包脚本示例:
#!/bin/sh
## chang here
SERVICE_DIR=/roncoo/spring-boot-demo
SERVICE_NAME=spring-boot-demo-31-1-0.0.1-SNAPSHOT
SPRING_PROFILES_ACTIVE=dev
## java env
export JAVA_HOME=/opt/jdk1.7.0_79
export JRE_HOME=${JAVA_HOME}/jre
case "$1" in
start)
procedure=`ps -ef | grep -w "${SERVICE_NAME}" |grep -w "java"| grep -v "grep" | awk '{print $2}'`
if [ "${procedure}" = "" ];
then
echo "start ..."
if [ "$2" != "" ];
then
SPRING_PROFILES_ACTIVE=$2
fi
echo "spring.profiles.active=${SPRING_PROFILES_ACTIVE}"
exec nohup ${JRE_HOME}/bin/java -Xms128m -Xmx512m -jar ${SERVICE_DIR}/${SERVICE_NAME}\.jar --spring.profiles.active=${SPRING_PROFILES_ACTIVE} >/dev/null 2>&1 &
echo "start success"
else
echo "${SERVICE_NAME} is start"
fi
;;
stop)
procedure=`ps -ef | grep -w "${SERVICE_NAME}" |grep -w "java"| grep -v "grep" | awk '{print $2}'`
if [ "${procedure}" = "" ];
then
echo "${SERVICE_NAME} is stop"
else
kill -9 ${procedure}
sleep 1
argprocedure=`ps -ef | grep -w "${SERVICE_NAME}" |grep -w "java"| grep -v "grep" | awk '{print $2}'`
if [ "${argprocedure}" = "" ];
then
echo "${SERVICE_NAME} stop success"
else
kill -9 ${argprocedure}
echo "${SERVICE_NAME} stop error"
fi
fi
;;
restart)
$0 stop
sleep 1
$0 start $2
;;
*)
echo "usage: $0 [start|stop|restart] [dev|test|prod]"
;;
esac
如果有条件,用jenkins自动构建比较好
源码面前,了无秘密