Ekansh Rastogi
Ekansh Rastogi

Reputation: 2526

Unable to use command line arguments to start spring boot aplication

I have the following things setup on my system.

  1. Ubuntu 16.04
  2. Gradle 3.0
  3. Java 1.8.0_91
  4. springBootVersion : 1.4.0.RELEASE

I am running the spring boot application from command line with the following arguments.

gradle -Dserver.port=8090 -Dspring.profiles.active=dev bootRun

following are the logs

Starting a Gradle Daemon, 3 stopped Daemons could not be reused, use --status for details
No active profile set, falling back to default profiles: default
Registering beans for JMX exposure on startup
2016-10-26 18:36:00.463  INFO 27743 --- [  restartedMain] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2016-10-26 18:36:00.584  INFO 27743 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)

when i do gradle --status the result is

No Gradle daemons are running.
   PID STATUS   INFO
 26929 STOPPED  (client disconnected)
 27086 STOPPED  (client disconnected)
 27202 STOPPED  (client disconnected)
 27367 STOPPED  (client disconnected)

I am not sure what's gone wrong here. I had been able to run this with no issues previously on older versions of spring boot and gradle.

However when i do

java -jar -Dspring.profiles.active=dev -Dserver.port=8090 build/libs/demo-0.0.1-SNAPSHOT.jar

I am able to run the application with desired arguments, on port 8090 and with dev profile.

Upvotes: 2

Views: 506

Answers (1)

ootero
ootero

Reputation: 3475

Try using:

java -Dspring.profiles.active=dev -Dserver.port=8090 -jar build/libs/demo-0.0.1-SNAPSHOT.jar

Upvotes: 2

Related Questions