做fpga的网站,论坛网站开发平台,部门网站建设的意义,网站设计模板免费下载一、读取配置文件的优先级默认#xff1a;Jar包同级目录的config目录Jar包同级目录classPath(即resources目录)的config目录classpath目录最高优先级的方式是项目启动时通过命令的方式指定项目加载核心配置文件#xff0c;命令如下java –jar xxxx.jar -Dspring.config.locat…一、读取配置文件的优先级默认Jar包同级目录的config目录Jar包同级目录classPath(即resources目录)的config目录classpath目录最高优先级的方式是项目启动时通过命令的方式指定项目加载核心配置文件命令如下java –jar xxxx.jar -Dspring.config.locationxxx/xxx/xxxx.properties如果Spring Boot在优先级更高的位置找到了配置那么它会无视优先级更低的配置二、编写执行脚本#!/bin/bash#这里可替换为你自己的执行程序,其他代码无需更改APP_NAMErcs-report-0.0.6-SNAPSHOT.jarJVM-server -Xms512m -Xmx512m -XX:PermSize64M -XX:MaxNewSize128m -XX:MaxPermSize128m -Djava.awt.headlesstrue -XX:CMSClassUnloadingEnabled -XX:CMSPermGenSweepingEnabledAPPFILE_PATH-Dspring.config.location/apps/report_test/config/application-uat.yml#使用说明,用来提示输入参数usage() {echo Usage: sh 执行脚本.sh [start|stop|restart|status]exit 1}#检查程序是否在运行is_exist(){pidps -ef|grep $APP_NAME|grep -v grep|awk {print $2} #如果不存在返回1,存在返回0if [ -z ${pid} ]; thenreturn 1elsereturn 0fi}#启动方法start(){is_existif [ $? -eq 0 ]; thenecho ${APP_NAME} is already running. pid${pid} .elsenohup java $JVM -jar $APPFILE_PATH $APP_NAME /dev/null 21 fi}#停止方法stop(){is_existif [ $? -eq 0 ]; thenkill -9 $pidelseecho ${APP_NAME} is not runningfi}#输出运行状态status(){is_existif [ $? -eq 0 ]; thenecho ${APP_NAME} is running. Pid is ${pid}elseecho ${APP_NAME} is NOT running.fi}#重启restart(){stopstart}#根据输入参数,选择执行对应方法,不输入则执行使用说明case $1 instart)start;;stop)stop;;status)status;;restart)restart;;*)usage;;esac2.1、使用脚本启动项目sh ***.sh startsh ***.sh stopsh ***.sh restartsh ***.sh status注意点1、如果脚本是在window系统写好接入linux系统执行脚本时会报错$’\r’: 未找到命令解决yum install dos2unixdos2unix **.sh 进行转换再次执行即可2、如果jar包和脚本不在同一路径需要在脚本中添加切换路径命令三、修改xml文件打jar包不打yml文件确保在启动项目时不会读取jar内的yml文件org.apache.maven.pluginsmaven-jar-plugin3.2.0application.yml