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

时间:2015-03-18 02:28:46

标签: spring-boot

我使用的是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

如何从命令行传递此参数?

1 个答案:

答案 0 :(得分:2)

通过

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

然后运行

gradlew bootRun -Dspring.profiles.active=prod
相关问题