Understanding embedded servers

Spring Boot brings in the concept of embedded servers, where the web server is part of the application deployable—JAR. To deploy applications using embedded servers, it is sufficient if Java is installed on the server.

The following diagram shows an example installation:

When we build any application with Spring Boot, the default is to build a JAR. With spring-boot-starter-web, the default embedded server is Tomcat.

When we use spring-boot-starter-web, a few Tomcat-related dependencies can be seen in the Maven dependencies section. These dependencies will be included as part of the application deployment package:

To deploy the application, we need to build a JAR. We can build a JAR using the following command:

mvn clean install

The following screenshot shows the structure of the JAR that was created.

BOOT-INFclasses contains all application-related class files (from srcmainjava), as well as the application properties from srcmain esources:

BOOT-INFlib contains all the JAR dependencies of the application. Tomcat-specific JARs enable the launch of an embedded Tomcat service when the application is run as a Java application. Because of this, a Java installation is sufficient to deploy this application on a server.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset