I have a few urls in application.properties of my jmix application. The urls are used to tell the application where to get it’s user authenticated. But now i want to deploy the application and want to externalize the urls. I have used jndi data source concept provided in the documentation for database externalization. How do i do the same with the urls? TIA
Hello,
I have some ideas to tell you about your problem.
The first thing that comes to my mind is to use spring profiles. It allows you to have several different .properties files with different configurations that you specify when the application is started, like this:
java -jar application-1.7.17-SNAPSHOT.jar --spring.profiles.active=abc
while having several profiles like this:
application.properties
application-dev.properties
application-abc.properties
When you specify abc, it will read the properties from there, and if property is not specified, it will read it from application.properties.
So, you place your new URLs into the desired profile and run it.
That way, it’s under your control, for security reasons.
Otherwise, the application needs to read your parameters from somewhere, externally, and that may not be good for security. You would also need to override the spring boot application start to read your parameters from somewhere outside, and then initialize the application properties before they are needed by the application. I have seen it done, but this will require more work than just using spring profiles.
Kind regards,
Mladen
Hi,
Since Jmix is just a Spring Boot App in this regard, you can use any configuration property and configure it as an ENV variable. Basically all properties that you can configure via application.properties, you can also configure via System Environment Variables.
See the Jmix Bookstore example, where this is done in the docker-compose.yml:
Cheers
Mario