Java,  Spring Framework

The Springboot web starter

Spring web starters are a common place to start building web applications or services and in the Spring world, web applications and services are considered as the same. A single application can contain both with no additional effort and use spring-boot-starter-web as the baseline module which has a set of components required to get a web application or service running.

The dependencies included in spring-boot-starter-web includes spring dependencies as well as dependencies from vendors such as Apache. Springboot takes care of the management of the various dependencies and their versions.

Embedded Tomcat

Spring-boot-starter-web contains an embedded Tomcat server by default so when you build an executable jar file, it will serve a web application. The Tomcat web server can be replaced by another web server if required by excluding the embedded web server and including the web server required in the pom.xml :

...
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
	<exclusions>
		<!-- Exclude the Tomcat dependency -->
		<exclusion>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
		</exclusion>
	</exclusions>
</dependency>
<!-- Use Jetty instead -->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
...

Tomcat can also be removed completely so that a WAR file can be created to be deployed onto another web server. To disable the embedded web server, configure the WebApplicationType in the application.properties :

spring.main.web-application-type=none

Tomcat’s default configuration may not be the most secure and this needs to be considered with the type of infrastructure it will be deployed to especially if being deployed onto the public cloud without a proxy layer in front of the application.

JSON Marshaller

JSON Marshaller is another useful feature in SpringBoot. The Springboot starter web provides a set of JSON Marshallers from the Jackson libraries to handle JSON marshalling and unmarshalling for RESTful web services and reading from a file system or a message listener.

A Spring application that is accepting a request or serving a response specific to a web service application path would automatically marshal/unmarshal the JSON payload. If required in a specific use case, a handle could be provided to the marshaller if you require to handle your own marshalling.

Testing

Testing is an integral part of the software development lifecycle. With SpringBoot, test dependencies are also provided to be able to unit and integration test the web services you build.