外部配置文件和Class打包到jar 然后重新启动java -jar

我这边以bpvs-backend-2.0.0-SNAPSHOT.jar和application-dev.properties配置文件为例

一.将DeviceDataService.class和DeviceDataPushTOSEventListener.class替换到jar内部
步骤1:解压原始bpvs-backend-2.0.0-SNAPSHOT.jar

将两个class文件拷贝到jar目录下后cd到文件目录执行:

jar xf bpvs-backend-2.0.0-SNAPSHOT.jar BOOT-INF/classes/com/boxplus/bpvs/device/
jar xf bpvs-backend-2.0.0-SNAPSHOT.jar BOOT-INF/classes/com/boxplus/bpvs/rpc/event/
步骤2:替换或添加class文件
copy DeviceDataService.class BOOT-INF/classes/com/boxplus/bpvs/device/
copy DeviceDataPushTOSEventListener.class BOOT-INF/classes/com/boxplus/bpvs/rpc/event/

步骤3:重新打包jar
jar uf bpvs-backend-2.0.0-SNAPSHOT.jar BOOT-INF/classes/com/boxplus/bpvs/device/DeviceDataService.class
jar uf bpvs-backend-2.0.0-SNAPSHOT.jar BOOT-INF/classes/com/boxplus/bpvs/rpc/event/DeviceDataPushTOSEventListener.class

二、优先加载外部的配置文件application-dev.properties,启动jar应用
java -jar -Dspring.config.location=file:C:/RunBPVS/application-dev.properties -Dspring.profiles.active=dev bpvs-backend-2.0.0-SNAPSHOT.jar COM3

你可能感兴趣的:(java,jar,pycharm)