How the Spring boot boot port starts _java

Source: Internet
Author: User

Spring Boot Boot port

Spring Boot is an integrated Web container by default, starting with the main function portal, like a normal Java program. Its built-in Tomcat container or jetty container, which is determined by the configuration (default tomcat). Of course, you can also package the project into a war package, put it in a separate Web container (Tomcat, WebLogic, and so on), and of course you have to make a simple adjustment to the program's entry.

Spring boot is a good thing that can be started directly in the main method without a container, and requires no configuration files to make it easy to build the environment quickly. But when we have to start 2 springboot projects at the same time, there is a problem, it is possible because the 8080 port is the first application to occupy the second application will not start, then need to modify the boot port of one of the works.

You can implement the Embeddedservletcontainercustomizer interface by implementing the following:

public class application extends Springbootservletinitializer implements Embeddedservletcontainercustomizer { 
 
  @ Override 
  protected Springapplicationbuilder Configure (Springapplicationbuilder builder) { 
    return Builder.sources (Application.class); 
  } 
   
  public static void Main (string[] args) { 
    springapplication.run (application.class, args); 
 
 
  @Override public 
  void Customize (Configurableembeddedservletcontainer container) { 
    container.setport (8081) ; 
  } 
} 

Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.