cirovladimir
cirovladimir

Reputation: 613

How to configure jhipster app to run on different port when launching with maven

Jhipster docs say you have to

mvn -Pprod package

and then you can execute the generated war with

java -jar jhipster-0.0.1-SNAPSHOT.war --spring.profiles.active=prod

you may configure the server port with

java -jar jhipster-0.0.1-SNAPSHOT.war --spring.profiles.active=prod --server.port=9000

as per the Spring Boot docs specify that command line arguments take precedence over application properties files and YAML variants.

But, when trying to run the app with maven on a different port

mvn -Pprod -Dserver.port=9000 spring-boot:run

it still reads the server.port from application-prod.yml

Upvotes: 3

Views: 7574

Answers (3)

Young Suk Ahn
Young Suk Ahn

Reputation: 93

For me, passing the SERVER_PORT as env variable worked:

SERVER_PORT=9000 mvn spring-boot:run

Spring translates the os env variables SERVER_PORT into spring's server.port configuration.

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-application-property-files

Upvotes: 0

Aman C
Aman C

Reputation: 119

mvn spring-boot:run -Drun.arguments="--server.port=9090"

Upvotes: 0

sdoxsee
sdoxsee

Reputation: 4681

mvn -Pprod spring-boot:run -Drun.arguments="--server.port=9000,--spring.profiles.active=prod"

Upvotes: 10

Related Questions