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?

1
  • 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 stackoverflow.com/questions/25079244/… Commented Mar 18, 2015 at 7:18

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.