Spring Boot boot port
Spring Boot is an integrated web container by default, and the startup method is started by the main function entry like a normal Java program. It has 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 and put it in an independent web container (Tomcat, weblogic, etc.). Of course, before this, you need to make simple adjustments to the program entrance.
Spring boot is a good thing. It can be started directly in the main method without a container, and there is no configuration file required, which is convenient and quick to build an environment. However, when we want to start two springboot projects at the same time, there will be problems. It is possible that the second application will not be started because the 8080 port is occupied by the first application. At this time, we need to modify the startup port of one of the projects.
It can be implemented by implementing the EmbeddedServletContainerCustomizer interface:
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 it can help you. Thank you for your support for this site!