How|How to load external property file in JBoss 7 classpath?

This page talks about how to bring application specific or external property file (any kind of file) into JBoss AS 7.x in the application classpath. Whenever we deploy our application into the application server like JBoss, it is good practice to seperate property files, configuration related files, etc out of deployment bundle. This way we can make sure that any configuration changes does not requires new build. We can edit the configurations in the external files and restart the application. Here are the steps to put external files into the JBoss AS 7.0 and above application classpath:
1) Create a new module for your application configuration files in the JBoss
Create folder structure as shown below and place a file called module.xml inside the last folder.
jboss-as-7-home-folder/modules/com/your-company/configuration/main/module.xml
Update your module.xml file with below shown content:
?
1 2 3 4 5 6 "1.0" encoding= "UTF-8" ?> "urn:jboss:module:1.1" name= "com.your-company.configuration" > "." />
2) Add all property files under main folder
You have already created folder structure, move all your property files under main folder, these files should be placed along with module.xml file.
3) Create jboss-deployment-structure.xml file in your application and map your module in the xml
Create jboss-deployment-structure.xml file under your application WEB-INF directory of your WAR file. Update your jboss-deployment-structure.xml file with the given below content:
?
1 2 3 4 5 6 7 8 "1.0" encoding= "UTF-8" ?> "com.your-company.configuration" />
【How|How to load external property file in JBoss 7 classpath?】4) Load a properties file from the classloader in your application
?
1 InputStream is = this .getClass().getClassLoader().getResourceAsStream( "MyAppProp.properties" );

    推荐阅读