Loading config files from Wildfly modules

/** Approach 1 **/
String secretKey;

if(env.equals("TEST")) {
secretKey = "randomTestValue";
} else if(env.equals("PRODUCTION")) {
secretKey = "realSecretKey";
/** Approach 2 **/@Inject
private String secretKey;
  1. Create a config.properties file with key-value pair.
  2. Place it outside the application or in your standard configuration folder inside wildfly modules folder. For ex: com/application/configuration/
  3. Create main folder and also add module.xml.
<module xmlns="urn:jboss:module:1.1" name="com.application.configuration">
<resource-root path="."/>
  1. Add jboss-deployment-structure.xml in the application with following minimal setting. For a web application (WAR) add this file to the WEB-INF directory. For an EJB archive (JAR) add it to the META-INF directory.
<module name="com.application.configuration" optional="true"/>
Dependencies: com.my-cdi-module meta-inf




Learn ✦ Explore ✦ Share

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Take part in the Solcial contest with prize pool 100k SLCL

The State within JavaScript

Give me a break

How to Create a News WebApp using Bootstrap, ReactJs and APIs

Writing a reusable data table function in Elm

Do/While and While Loops, and Conditionals

New in MicroStation CONNECT Edition Update 16.1 — Parametric Modeling

JavaScript Arrow Functions (Beginner Friendly)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Salu Khadka

Salu Khadka

Learn ✦ Explore ✦ Share

More from Medium

Introducing Rachel: Software Developer

React + TS: Organizing API data

Increase the security and simplicity of your Information System with OpenID Connect

Focus on the item-stock API of your Information SystemFocus on the item-stock API of your Information System

How to use URL Parameters to Set State With React Hooks