SpringBoot Internal webserver
First of all, spring boot isn’t one of server. It just create WebServer instance internally.
To create internal WebServer, like below.
- Create Tomcat Object.
- Set port.
- Add context at Tomcat.
- Create Servlet.
- Add Servlet at Tomcat.
- Mapping Servlet at Tomcat.
- Execute Tomcat and wait.
Here is executable WebServer without Springboot internal WebServer.
1 | public static void main(String[] args) throws LifecycleException { |
But, If use SpringBoot, do not have to care about above setting.
SpringBoot execute internal WebServer write as below code.
1 | SpringApplication app = new SpringApplication(Application.class); |
If don’t want running as WebServer, can write below setting at application.properties
.
1 | spring.main.web-application-type=none |
Then, SprungBoot run as normal application.
Also can setting port number what you want as shown below.
1 | server.port=7070 |
If want setting an available port automatically, write code as shown below.
1 | server.port=0 |