I would like to package my spring boot application as war for a specific profile. That can be done with setting spring.profiles.active=profile name in application.properties file. Is it possible to set it as a parameter when building war eg. gradle build --spring.profiles.active=profile name?
It sounds like you want to bake the value of spring.profiles.active
into the war when it's built. You can do so using Gradle's support for resource filtering. Configure your application.properties
like this:
spring.profiles.active=@activeProfiles@
And then apply filtering in your build.gradle
to replace @activeProfiles@
with the value of a property:
processResources {
filter org.apache.tools.ant.filters.ReplaceTokens, tokens: [
activeProfiles: activeProfiles
]
}
In this example, I've used a property named activeProfiles
. You'd then have to supply a value when you run the build:
./gradlew -PactiveProfiles=foo build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With