java 如何在 JBoss 中设置环境变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30350250/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 16:58:59  来源:igfitidea点击:

How to set environment variables in JBoss

javatomcatjakarta-eejbosswebserver

提问by Shekhar Khairnar

We are developing an application that is deployed in a JBoss. we would like to define a properties files like this:

我们正在开发一个部署在 JBoss 中的应用程序。我们想定义这样的属性文件:

URL_DEVELOPMENT.properties = ...
URL_TEST.properties = ...
URL_PRODUCTION.properties = ...

and define an environment variable in the JBoss which contains the information about the execution context

并在 JBoss 中定义一个环境变量,其中包含有关执行上下文的信息

for example --> ENVIRONMENT = DEVELOPMENT

Anyone knows:

有谁知道:

1) How to set environment variables in JBoss.

1) 如何在 JBoss 中设置环境变量。

2) How to get these variables from an applicacion deployed in JBoss in runtime execution?

2) 如何在运行时执行中从部署在 JBoss 中的应用程序中获取这些变量?

Thank you !

谢谢 !

回答by maress

The easiest and most straight forward way is to log into jboss web admin: www.yoururl:9990

最简单直接的方法是登录 jboss 网络管理员: www.yoururl:9990

Then under configuration, look for system property.

然后在配置下,查找系统属性。

At runtime, it is very easy: System.getProperty(yourPropertyKey)and the good thing is that a change in any of these properties is reflected immediately at runtime.

在运行时,这很容易:System.getProperty(yourPropertyKey)而且好消息是这些属性中的任何一个更改都会在运行时立即反映出来。

The other scenario is to open up standalone.xml

另一种场景是打开standalone.xml

<server ...>
   <system-properties>
        <property name="eclipselink.archive.factory" value="org.jipijapa.eclipselink.JBossArchiveFactoryImpl"/>
   </system-properties>
</server>

The other option is to read on jboss cli and configure system properties from there. (Only useful if you want to work with remote jboss and you cannot ssh into the server, and you cannot access the web admin)

另一种选择是阅读 jboss cli 并从那里配置系统属性。(仅当您想使用远程 jboss 并且无法通过 ssh 进入服务器且无法访问 Web 管理员时才有用)