spring.profiles.active 无法从命令行运行

spring.profiles.active is not working from the command line

我正在使用 spring-boot: 1.2.2

这是 docs 中提供的语法(当我开始使用命令时得到 Unknown command-line option '--spring.profiles.active'.

gradlew bootRun --spring.profiles.active=noAuthentication

我试过了,但没用

gradlew bootRun -Dspring.profiles.active=noAuthentication

我在其他地方发现这应该有效,但没有

gradlew bootRun -Drun.jvmArguments="-Dspring.profiles.active=noAuthentication"

我将以下内容添加到 application.properties 并且它工作正常。

spring.profiles.active=noAuthentication

如何从命令行传递这个参数?

已通过

修复
project.gradle.projectsEvaluated {
    applicationDefaultJvmArgs = ["-Dspring.profiles.active=${project.gradle.startParameter.systemPropertiesArgs['spring.profiles.active']}"]
}

和运行

gradlew bootRun -Dspring.profiles.active=prod