Gradle build spring boot app as war with active profile

拜拜、爱过 提交于 2019-12-01 18:25:11

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!