简体   繁体   中英

How to set environment variables in JBoss

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

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

for example --> ENVIRONMENT = DEVELOPMENT

Anyone knows:

1) How to set environment variables in JBoss.

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

Thank you !

The easiest and most straight forward way is to log into jboss web admin: 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.

The other scenario is to open up 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM