If you are starting to implement a spring mvc project, a lot of configuration or steps you need to do. May be if we can start with pom.xml, you need a lot of dependencies to mention in it, may be it is a web dependency ,database dependencies,if spring is integrated with any orm framework then that dependency and a lot of….

And now if you want to implement many such spring mvc projects then you need to repeat this again. Is that redundant and troublesome always right?

Here comes a great solution to these problems.. It’s Spring Boot !!

Welcome to Spring Boot! Spring Boot does what exactly you are looking for. It will do things automatically for you but allows you to override the defaults if you want to.

Now if you consider pom.xml, Spring boot provides many less dependencies which contain a lot of inner dependencies. For eg: Refer to below pomm.xml from spring boot.

images

As you can see we have a parent – spring-boot-starter-parent. This is a parent pom providing dependency and plugin management for applications built with Maven

If you consider spring-boot-starter-web, this will provide all the libraries which provides spring mvc support. In this way there are very less dependencies which internally provides libraries to start the application. Some advantages of Spring boot can be listed as below.

  1. Very less dependencies to start writing application code
  2. Very rich in implementing microservices.
  3. Provides an embedded tomcat container, so you can test your services fast.
  4. Provides inbuilt H2,derby databases so no need to worry on that part.
  5. The default configurations can be easily overrided .
  6. Provide production-ready features such as metrics, health checks and externalized configuration.

Spring boot application can easily using a main method. Consider below code

Untitled

As you can see, We have a main method which has SpringAppliation.run(), which boots up the spring application. @SpringBootApplication is a combination of three annotations

-@Configuration,@EnableAutoConfiguration and @ComponentScan

  • @Configuration : This annotation is not specific to the spring boot applications. This annotation tags the class as the source for bean definitions. In short, this annotation is used for defining beans using the Java configuration.
  • @EnableAutoConfiguration : This is a spring boot annotation. This annotation enables the application to add the beans using the classpath definitions.
  • @ComponentScan : This annotation tells the spring to look for other components, configurations and services in the specified path.

Thus we can use a single annotaion @SpringBootApplication, which combines the above all three.

Also as I said that Spring boot consists of embedded tomcat container, if you want a some different container, you can just change the entry in the pom.xml.

As in all, Spring boot is becoming more popular these days for rapid fast development.

For more information on spring boot you can refer – spring boot.