我具有以下Web应用程序的kts Gradle配置:
tasks.withType<ProcessResources> {
filesMatching("application-test.yaml") {
expand(project.properties)
}
}
application-test.yaml
看起来像
spring:
datasource:
hikari:
maximum-pool-size: 25
username: ${DB_USERNAME:user}
password: ${DB_PASSWORD:password}
url: ${DB_CONNECT_URL:jdbc:postgresql://localhost:5432/database}
当我执行命令时:
./gradlew clean test -PDB_PASSWORD=password -PDB_USERNAME=error_user -PDB_CONNECT_URL=jdbc:postgresql://localhost:5432/database
groovy脚本中存在错误:
Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript6.groovy: 9: unexpected token: @ line 9, column 40.
但是如果删除默认值,一切正常。 我试图
${DB_PASSWORD?!password}
帮我的一件事是kts代码用build.gradle.kts
获取和替换filter<ReplaceTokens>
中的属性。
也许有人知道另一种方式?