@T基于jar包带参数的java软件部署OC
windows环境:
可用已下命令启动:
```powershell
java -jar xxx.jar --spring.datasource.url=jdbc:mysql://1.2.3:3308/dbname? --useUnicode=true --characterEncoding=utf-8 --useSSL=true --allowMultiQueries=true --serverTimezone=UTC --spring.datasource.username=username1 --spring.datasource.password=password1
linux环境:(可在后台关闭窗口继续运行)
```powershell
nohup java -jar -Dspring.datasource.url="jdbc:mysql://1.2.3.4:3308/vela_evs?" -DuseUnicode=true -DcharacterEncoding=utf-8 -DuseSSL=true -DallowMultiQueries=true -DserverTimezone=UTC -Dspring.datasource.username="usname" -Dspring.datasource.password="pword" /opt/xx/xx.jar > /opt/xxx/xx.out &
启动配置读取优先级:
高:命令参数
中:jar包同级下的config文件夹中的application.properties.
低:软件中:resource下的application.properties.
注意:若优先级高的里无某个参数,会以优先级低的里边的参数值为准。三个文件都会读。
注意:1.这里边一定要加args,相当于外部参数
public static void main(String[] args) {
SpringApplication.run(ServiceManApplication.class, args);
}
2.如果运用到spring cloud的配置中心,一定要注释掉配置中心的相关参数,命令里的才不会覆盖。