i'm working on spring boot project and all works fine , now i want to build and run the app.
in the application.properties file i set the property server.port = 8090
after building the project using maven i run the following command
java -jar jarfilename.jar
but it says the port 8080
is already in use.
i try these commands:
java -jar -Dport=8090 jarfilename.jar
and
java -jar jarfilename.jar --port=8090
but also i got the same message the port 8080
is already in use.
I'm wondering why it takes the port number 8080
and ignore the port number 8090
that i set in the application.properties file.
Note : (I'm using tomcat embedded server) and when i check the folder target/classes.. application.properties i didn't find the property server.port=8090
.
can anyone explain to me what' happen exacly? thanks in advance.
Is the application.properties located at the right location? Description from Spring.io:
SpringApplication will load properties from application.properties files in the following locations and add them to the Spring Environment:
- A /config subdirectory of the current directory.
- The current directory
- A classpath /config package
- The classpath root
The list is ordered by precedence (properties defined in locations higher in the list override those defined in lower locations).
Use java -jar -Dserver.port=8090 jarfilename.jar
to set the port from command line.
Hint, from Spring.io: If you want to use the short term -Dport=8090
, you can use server.port=${port:8080}
in your application property file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With