How to add command line properties with gradle bootRun?

时间:2018-08-22 13:44:14

标签: java spring spring-boot

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?

1 个答案:

答案 0 :(得分:1)

BootRun任务扩展了JavaExec任务:https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/gradle-plugin/api/org/springframework/boot/gradle/tasks/run/BootRun.html

从Gradle 4.9开始,可以使用--args传递命令行参数。例如,如果要使用命令行参数foo --bar启动应用程序,则可以使用:

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