Spring boot is a good thing to start without a container directly in the main method, and you don't need to configure the file to quickly build your environment. However, when we want to start 2 springboot projects at the same time, there is a problem, it is possible that the second application will not start because the 8080 port is occupied by the first application, then you need to modify the boot port of one of the projects.
This can be achieved by implementing the Embeddedservletcontainercustomizer interface:
Public classApplicationextendsSpringbootservletinitializerImplementsEmbeddedservletcontainercustomizer {@OverrideprotectedSpringapplicationbuilder Configure (Springapplicationbuilder builder) {returnBuilder.sources (Application.class); } Public Static voidMain (string[] args) {springapplication.run (application.class, args); } @Override Public voidCustomize (Configurableembeddedservletcontainer container) {Container.setport (8081); } }
Spring boot modifies the boot port