[英]Profile change is not working with gradle in jhipster 7
更改配置文件不適用於使用 jhipster(v7.3 和 7.4)和 gradle 生成的應用程序。 我跟着這個。 當我從命令行gradlew -Pprod
運行時,應用程序總是在開發配置文件中啟動:
No active profile set, falling back to default profiles: dev,api-docs
我認為生成器出了問題,因為沒有人提供spring.profiles.active
屬性。 我在以前的版本中看到的profile_prod.gradle文件中錯過了it.replace('#spring.profiles.active#', profiles)}
。 我添加了它,現在build文件夾中的application.yml包含spring: profiles: active: prod
,但應用程序一直默認為 dev。
這是我的profile_prod.gradle :
dependencies {
testImplementation "com.h2database:h2"
}
def profiles = "prod"
if (project.hasProperty("no-liquibase")) {
profiles += ",no-liquibase"
}
if (project.hasProperty("api-docs")) {
profiles += ",api-docs"
}
springBoot {
buildInfo()
}
bootRun {
args = []
}
processResources {
println 'I'm running -Pprod!'
inputs.property('version', version)
inputs.property('springProfiles', profiles)
filesMatching("**/application.yml") {
filter {
it.replace("#project.version#", version)
}
}
}
這似乎是一個錯誤,我打開了一個問題,同時這個解決方法有效:
添加到 processResources 配置: filter { it.replace('#spring.profiles.active#', profiles) }
刪除或注釋bootstrap.yml文件,它有一個空的 spring.profiles.active 覆蓋之前的替換。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.