我需要一个自定义属性来为Weblogic中的每个服务器JVM设置.这样做的好方法是什么?
我知道我们可以指定如下的论据:
我的问题是如何定义参数?如何在将在JVM中部署的应用程序中使用该参数.
编辑
如果我指定,-DMyArg=MyValue
并在代码中,value=System.getproperty("MyValue"); 这应该工作,对吧?
我有一个将在各种环境中运行的Spring Boot应用程序,并且根据它运行的环境,它将连接到不同的数据库.我有几个application.properties文件,每个环境对应一个文件:
application-local.properties:
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://localhost:5432/mydb
spring.datasource.username=dbuser
spring.datasource.password=123456789
Run Code Online (Sandbox Code Playgroud)
application-someserver.properties:
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://someserver:5432/myproddb
spring.datasource.username=produser
spring.datasource.password=productionpass
Run Code Online (Sandbox Code Playgroud)
等等
在我的每个环境中,我都有一个环境变量MYENV,例如,它被设置为环境类型,local或者someserver(application-{env}.properties文件的名称与环境名称完全匹配).
如何让spring boot读取这个环境变量并自动选择正确的.properties文件?我不想做整个-Dspring.profiles.active=someserver因为这个包的部署方式(它不会作为jar运行).