Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot + gradle pass comand line args to application.property

I use Spring Boot with Gradle, I execute this in Intelij:

10:43:37: Executing external task 'bootRun  -Drun.arguments="--
server.port=6666"'...

but still in logs I see:

Tomcat initialized with port(s): 8080 (http)

I have seen this, but it does not work for me: https://stackoverflow.com/a/37053004/3871754

like image 489
Kamil Nękanowicz Avatar asked Dec 14 '22 19:12

Kamil Nękanowicz


1 Answers

Using Command Line Arguments with the Spring Gradle BootRun task isn't readily apparent. Here is a very interesting discussion on the topic in this Spring Boot Issue Thread.

How you can do it today is by passing all system properties to the bootRun task as mentioned in the thread, like this.

bootRun {
    systemProperties = System.properties
}

Then you can use simply:

bootRun -Dserver.port=6666

s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 6666 (http)

like image 59
Kamil Nękanowicz Avatar answered Dec 16 '22 08:12

Kamil Nękanowicz