I have two applications that I need to run simultaneously, and both are trying to run on port 8080
. I'd like to change one of them to port 9000
. The application I'm trying to change has spring security, so it runs on port 8443
when using https
and port 8080
when using http
. I have to move it from port 8080
without changing any .java
files. Also, I need to run the other application on port 8080
as well, so changing the default tomcat port wouldn't be a good idea.
I tried adding to application.properties
the lines server.port=9000
, spring.main.server.port=9000
, then running mvn install
, and then java -jar target/app.jar
.
I also tried running java -jar target/app.jar
with different flags: -Dserver.port=9000
and --server.port=9000
.
Regardless, I get - Tomcat started on port(s): 8443 (https) 8080 (http)
.
So, my questions are:
8080
?Run the following command:
mvn spring-boot:run -Drun.jvmArguments='-Dserver.port=8088'
Add the following plugin
to your pom.xml
file
<build>
. . .
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
If you want to change spring boot default port without change any code you should pass port number in spring boot run command as
java -jar -Dserver.port=8090 hello-spring-boot.jar
Now your application will use 8090 port.
Reference : How to Change the default port in Spring Boot
In Other method we can add server.port property in application.properties file
server.port = 8090
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.