Embedded servers

One of the important concepts Spring Boot brings in is embedded servers.

Let's first understand the difference between traditional Java web application deployment and this new concept called embedded server.

Traditionally, with Java web applications, we build Web Application Archive (WAR) or Enterprise Application Archive (EAR) and deploy them into servers. Before we can deploy a WAR ;on the server, we need a web server or an application server installed on the server. The application server would be on top of the Java instance installed on the server. So, we need Java and an application (or web server) installed on the machine before we can deploy our application. The following figure shows an example installation in Linux:

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 figure 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 command below:

mvn clean install

The following screenshot shows the structure of the JAR created.

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

Some of the libraries in ;BOOT-INFlib are ;shown in the following screenshot:

BOOT-INFlib contains all the JAR dependencies of the application. There are three Tomcat-specific JARs among these. These three 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