Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding spring-boot application properties when deploying in JBoss

I have a Spring-Boot based app with YAML based configuration, I have no problem changing the properties when I run with java -jar app.war -Dnamespace.properties=different_value, but now I have to deploy the application into a JBoss EAP, I succesfully build the war file but I want to modify the properties (override some of the YAML values), without needing to modify the war.

Documentation mentions

  • JNDI attributes from java:comp/env.
  • Java System properties (System.getProperties())

As alternatives, but I have no idea how to set up those. Some ideas ?

BONUS: It would be nice to modify the properties in run-time without needing to redeploy the app

like image 957
carpinchosaurio Avatar asked Oct 09 '17 15:10

carpinchosaurio


People also ask

Can we override application properties in spring boot?

To override your Spring Boot application properties when it's running on Kubernetes, just set environment variables on the container. To set an environment variable on a container, first, initialise a ConfigMap containing the environment variables that you want to override.

Can we deploy spring boot application in JBoss?

With this configuration, the application is ready to deploy to any external application server. Once this is done, you can package your Spring Boot application as a war and deploy it to the JBoss server. To do that, you need to run mvn clean package , which will generate the war file.

Is application properties mandatory in spring boot?

So in a spring boot application, application. properties file is used to write the application-related property into that file. This file contains the different configuration which is required to run the application in a different environment, and each environment will have a different property defined by it.


1 Answers

You can add system properties in the standalone.xml

<system-properties>
  <property name="my.property" value="Hello"/>  
</system-properties> 

System properties in JBoss EAP can be changed at runtime using CLI or the Webinterface and some other ways.

If your application is reloading it depends on where the properties are used.

What property do you want to override?

like image 82
Simon Martinelli Avatar answered Sep 26 '22 15:09

Simon Martinelli