Know the Difference Between Spring Boot and Spring

Posted By : Santosh Kumar Sah | 30-Sep-2019

 

1. Spring

 

Spring framework comes with a lot of features like dependency injection and several out of the box modules

- Spring JDBC
- Spring MVC
- Spring Security
- Spring AOP
- Spring ORM
- Spring Test

Using these modules we can effectively decrease the application development time.

 

2. Spring Boot

 

Spring Boot basically sets up the environment for development, it configures the project itself and makes development furthermore efficient.

Features:

- The server is embedded to ease the build and configuration of the application.
- Spring functionality is automatically configured.

 

3. Maven Dependencies

 

In Spring we need to add a minimum two dependencies spring-web and spring-webmvc.

In Spring boot we only need one dependency which is spring-boot-starter-web, rest of the required dependencies are automatically configured.

 

4. MVC Configuration

 

In Spring we need to define the Dispatcher Servlet, mapping, and some other configurations.

Example:


public class MyWebAppInitializer implements WebApplicationInitializer {
  
    @Override
    public void onStartup(ServletContext container) {
        AnnotationConfigWebApplicationContext context
          = new AnnotationConfigWebApplicationContext();
        context.setConfigLocation("com.baeldung");
  
        container.addListener(new ContextLoaderListener(context));
  
        ServletRegistration.Dynamic dispatcher = container
          .addServlet("dispatcher", new DispatcherServlet(context));
          
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");
    }
}

In Spring boot we only need a few entries after adding the web starter.

Example:

 

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

 

5. Packaging and Deployment

 

Spring Boot has some advantages over the Spring if we consider deployment

- Support of Embedded container
- We can run jars independently using java-jar
- We can generate random ports for integration testing
- We can specify active profile while deploying

 

6. Conclusion

 

Spring boot is the extension of Spring and provides ease in deploying, building and test the application.

About Author

Author Image
Santosh Kumar Sah

He likes to learn new technologies. He primarily works in java and always look forward to learn more.

Request for Proposal

Name is required

Comment is required

Sending message..