I am using spring-boot with maven, this is my configuration class:
package hello;
import javax.servlet.MultipartConfigElement;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
When the app starts show this line in console:
2014-11-06 17:00:55.102 INFO 4669 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080/http
I want to change the TomcatEmbedded port to 8081 for the case. Thanks :D
The Spring Boot framework provides the default embedded server (Tomcat) to run the Spring Boot application. It runs on port 8080. It is possible to change the port in Spring Boot.
Where do you set the port? Try using 2 different run configurations with the port set in the VM Options field like this: -Dserver. port=9090 . Use different port for each configuration so that you can run 2 instances.
Set the value via the server.port
property, just like explained in the documentation, e.g.:
mvn spring-boot:run -Drun.jvmArguments='-Dserver.port=8081'
There are 3-4 ways to change it. Add application.properties under
src/main/resources/
and add the property as below to the file:
server.port = 8084
For other ways to change, go through this link.
Spring official documentation link for the same.
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