3

I am using spring-boot: 1.2.2

This is the syntax supplied in the docs (I get Unknown command-line option '--spring.profiles.active'. when I start using the command)

gradlew bootRun --spring.profiles.active=noAuthentication

I tried this but it does not work

gradlew bootRun -Dspring.profiles.active=noAuthentication

I have found elsewhere that this should work but it does not

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

I added the following to application.properties and it works correctly.

spring.profiles.active=noAuthentication

How to you pass this argument from the command line?

jax
  • 37,735
  • 57
  • 182
  • 278
  • 2
    You pass the command line args to Gradle not to your Spring Boot app. See this answer to see how to pass args to the app via Gradle bootRun http://stackoverflow.com/questions/25079244/how-to-pass-jvm-options-from-bootrun – derkoe Mar 18 '15 at 07:18

1 Answers1

2

Fixed it via

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

And run

gradlew bootRun -Dspring.profiles.active=prod
user634545
  • 9,099
  • 5
  • 29
  • 40
abosancic
  • 1,776
  • 1
  • 15
  • 21