Jingguo Yao
Jingguo Yao

Reputation: 7986

How to add command line properties with gradle bootRun?

24.3 Application Property Files uses the following command to add an application property spring.config.name:

$ java -jar myproject.jar --spring.config.name=myproject

How can I do this with gradle bootRun?

Upvotes: 20

Views: 25236

Answers (2)

paul beuk
paul beuk

Reputation: 21

Alternatively you can add arguments in the build.gradle file

tasks{
    bootRun {
        args("myarg")
    }
}

Upvotes: 1

jreznot
jreznot

Reputation: 2773

BootRun task extends JavaExec task: https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/gradle-plugin/api/org/springframework/boot/gradle/tasks/run/BootRun.html

Since Gradle 4.9, the command line arguments can be passed with --args. For example, if you want to launch the application with command line arguments foo --bar, you can use:

gradle bootRun --args='--spring.config.name=myproject'

Upvotes: 35

Related Questions