Deploy two Spring Boot applications in Wildfly with external properties

Personally I prefer jar then war ("Make JAR, not WAR" - Josh Long), but sometimes we have constraints that are not depend on us.
This example focus about how to deploy two Spring Boot applications in Wildfly and how to externalize application properties for each application.

The case is:

  • deploy two Spring Boot applications in Wildfly,
  • each application has its own properties,
  • properties need to be loaded from external source (not from jar)

There is also alternative solution for example use of Spring Cloud Config, but it requires additional server.

Let's assume that we have two microservices.
Service1 with properties:

  • speedlog.common-name-property
  • service1.specific

Service2 with properties:

  • speedlog.common-name-property
  • service2.specific

Because we have two application that has property with the same name (speedlog.common-name-property) we can't set this property in:

  • environment variable
  • system properties
  • JVM args of Wildfly

If we do so, both applications would have the same value of this property.
So let's check how we can externalize properties for both applications.

We will add to each application actuator library to easy check properties value in runtime.
We also need to expose "env" endpoint in properties.
So in each application resources we have something like this:


3# some properties
4speedlog.common-name-property="this should be overwritten after deploy"
5service1.specific="this should be overwritten after deploy"


3# some properties
4speedlog.common-name-property="this should be overwritten after deploy"
5service2.specific="this should be overwritten after deploy"

Now let's imagine that we need to override preferences from application resources, when we deploy it in Wildfly.

Example solution may be a JBoss/Wildfly module with application properties file.

Below instructions for service1. For service2 it will be analogous:

  1. We need to add some files in application sources. service1/scr/main/webapp/WEB-INF/jboss-deployment-structure.xml
1<?xml version="1.0" encoding="UTF-8"?>
3    <deployment>
4        <dependencies>
5            <module name="pl.speedlog.example.twoappinwildfly.service1.configuration"/>
6        </dependencies>
7    </deployment>

In this file we declare where JBoss/Wildfly should find configuration of our module.

And optional we can add in the same directory (WEB-INF) file jboss-web.xml to declare root context (URL) of application.

1<?xml version="1.0" encoding="UTF-8"?>
2<jboss-web xmlns=""
3           xmlns:xsi=""
4           xsi:schemaLocation="
7    <context-root>service1</context-root>
  1. Now we add a module to Wildfly.
    In Wildfly "module" directory add directory tree that we declare in jboss-deployment-structure.xml.
    So we should create directory pl/speedlog/example/twoappinwildfly/service1/configuration and then additional "main" directory.

  2. Add module definition and properties file for application.
    In directory that we create in previous point, we create file module.xml.
    The "name" of module should be the same as in jboss-deployment-structure.xml in source code of application.

1<?xml version="1.0" encoding="UTF-8"?>
2<module xmlns="urn:jboss:module:1.1" name="pl.speedlog.example.twoappinwildfly.service1.configuration">
3    <resources>
4        <resource-root path="."/>
5    </resources>

And now we can create for our application.

3# override properties
4speedlog.common-name-property="This is text from jboss module of service 1"
5service1.specific="Service 1 specific"

If you place here file it will override properties file from application resources!

Just want to override only few properties? There is a simple solution.

a) create file with override properties with profile name for example:
b) add to your system environment variable to run application in “uat” profile:


Now application should load application properties from in application resources and from JBoss/Wildfly module.

  1. Now just deloy app in Wildfly and you can check value of properties by link:

Described example with two deployed application is on github:

Declaration of JBoss/Wildfly module is here: