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!