Skip to content

Spring Vs Spring Boot

Spring framework

Spring framework is the most widely used Java framework for building application. Spring framework has a lot of projects to develop java application.

Spring framework

For example:

You can avoid a lot of boilder plate code with Spring JDBC rather than using Java’s JDBC APIs.

Spring boot

As already stated above, Spring boot helps you to create Spring projects faster by eliminating boilerplate configurations.

It takes an opinionated view of Spring platform to bootstrap application faster.

Here are some advantages of Spring boot

Advantages of Spring Boot

  • Spring provides a lot of default configurations which helps in bootstrapping spring application faster.
  • It comes with embedded tomcat or jetty server.
  • It reduces development time by avoiding a lot of boilerplate code.
  • It increases productivity as you can create Spring application quickly.
  • It provides a lot of starter project for easy maven integration. You don’t have to worry about version mismatch.
  • You can quickly create using sample project using spring boot initializer

Spring vs Spring boot

We will see how Spring boot can reduce your efforts to bootstrapping any spring application.

Let’s say you want to create a web application.

We need to declare DispatcherServlet in web.xml for spring MVC. When DisplatcherServlet is initialized, spring tries to load application context from [servlet name]-servet.xml file

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">   
<display-name>Archetype Created Web Application</display-name> 
  <welcome-file-list>      <welcome-file>index.jsp</welcome-file>   

</welcome-file-list>   <servlet>     
 <servlet-name>springmvc-dispatcher</servlet-name>  
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>      
<load-on-startup>1</load-on-startup>   </servlet>   
<servlet-mapping>      <servlet-name>springmvc-dispatcher</servlet-name>     
 <url-pattern>/</url-pattern>  
 </servlet-mapping>
</web-app>

Configuration in “springmvc-dispatcher-servlet.xml” to provide InternalResourceViewResolver.

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">   <context:component-scan base-package="org.student.bootcamp.springmvc.controller" />   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">      <property name="prefix">         <value>/WEB-INF/</value>      </property>      <property name="suffix">         <value>.jsp</value>      </property>   </bean>   <mvc:annotation-driven /></beans>

If you want to do same thing using Spring boot

 spring.mvc.view.prefix=/WEB-INF/
spring.mvc.view.suffix=.jsp 

All the Spring configuration will be automatically loaded by adding Spring boot starter and it will take care of all the default configurations.
If you want to do any customization, it is very easy to do with Spring boot.

That’s all about difference between Spring and Spring boot.

Translate »