Dynamically loading property value from active list of profiles and set the value in configuration XML file

80
February 14, 2021, at 07:50 AM

I have a spring bath application which contains a batch configuration. I want to dynamically load profile based upon the environemnt variable parameter of active profile list.once i get the value, I have to set the variable in the batch configuration xml file. Its working fine while active profile value is single, its working fine if I give like

<context:property-placeholder location="classpath:application-${spring.active.profile}.properties" /> 

But i have a list of active profiles eg: -Dspring.active.profile=dev,localproperties,mycerts. I want to take first value of active profile and load properties file and load application-dev.properties. I tried the below way , but getting the entire entire string as profile value. how can i load the first value of active profile/.

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <util:list>
                <value>classpath:application-${spring.profiles.active}.properties</value>
            </util:list>
        </property>
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
    </bean>

How could I achieve this?

READ ALSO
WorkManager using setForegroundAsync() with ListenableWorker

WorkManager using setForegroundAsync() with ListenableWorker

A very useful guide and code snippet is provided for using setForegroundAsync() for a long-running worker in the context of a Worker in WorkManager

84
Update XML with an SQL query

Update XML with an SQL query

Let's say we have the following XML file:

81
TypeError: bdcls.map is not a function

TypeError: bdcls.map is not a function

I am finding it hard to consume data from the API i hosted on heroku using Axios

70
Binding a value to input form select-element in Blazor only sets the value after making a selection

Binding a value to input form select-element in Blazor only sets the value after making a selection

I am using Blazor Server and trying to bind a value to the selected option in a HTML form

32