In spring , we can configure the default port by setting the specific property when starting the application or by customizing the embedded server configuration.

For that, we will set our @SpringBootApplication class :

@SpringBootApplication
public class CustomApplication {
    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(CustomApplication.class);
        app.setDefaultProperties(Collections
          .singletonMap("server.port", "8083"));
        app.run(args);
    }
}

Here we changed the default Tomcat port 8080 to 8083. We can use a Command-Line Arguments to change the default port .

Commentaires

  1. Pingback: (Solved) How to Change the Default Port in Spring Boot ? » JavaTuto

Laisser un commentaire