Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Spring Boot

I am trying to understand the difference between spring boot and spring boot web. From this boot tutorial the pom contains spring boot as the parent and spring boot web as a dependency like so:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.1.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

What are the uses for the 2 different versions? Do you always use them together? This spring boot documentation tells me if the program is production ready to use:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
</dependencies>

But if that's the case then why isn't there one for web like so:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web-actuator</artifactId>
    </dependency>
</dependencies>
like image 511
Richard Avatar asked Jan 14 '16 20:01

Richard


3 Answers

There are lots of these different 'starter' poms for spring boot. Each one of them tells maven to bring in the dependencies needed for that particular functionality. So spring-boot-starter-web brings in all the stuff needed for MVC and autoconfigures it with sensible defaults. The real trick to spring boot is it when it autoconfigures things it uses a whole of @ConditionalOnClass or other such annotations that look at what dependencies are on the classpath and provides configuration for those dependencies. What this means is when you have that spring boot actuator starter, when it's doing its autoconfiguration it will look at what other spring boot start poms you have in your pom.xml and it will configure different endpoints for the actuator so you can see the various metrics the actuator provides for that particular module.

like image 50
james_s_tayler Avatar answered Nov 16 '22 04:11

james_s_tayler


Spring Boot is a framework, spring-boot-starter-web is one of the packages that comes with it, a jar file.

Just like JDK is a library, and util is one of the packages included in the JDK.

like image 3
OPK Avatar answered Nov 16 '22 03:11

OPK


From: https://docs.spring.io

Spring Boot provides a number of “Starters” that auto-configures your application adds jars to your classpath. The spring-boot-starter-parent is a core starter that provides useful maven defaults. It also provides a dependency-management section so that if you import additional starters then you can omit version tags for “blessed” dependencies. Therefore you should only need to specify the Spring Boot version number on this dependency

Starters are a set of convenient dependency descriptors that you can include in your application considering each starter covers a specific area.The starters contain a lot of the dependencies that you need to get a project up and running quickly and with a consistent, supported set of managed transitive dependencies.For example, if you want to get started using Spring and JPA for database access, just include the "spring-boot-starter-data-jpa" dependency in your project, and you are good to go. Spring Boot spring-boot-starter-web is starter for building web, including RESTful, applications using Spring MVC. It uses Tomcat as the default embedded container

Spring Boot has different groups of starters like

1-Spring Boot application starters: spring-boot-starter-web , spring-boot-starter-jdbc , spring-boot-starter-jpa etc

2-Spring Boot production starters : spring-boot-starter-actuator which provides production ready features to help you monitor and manage your application

3-Spring Boot technical starters: spring-boot-starter-jetty , spring-boot-starter-tomcat these starters can be used to exclude or swap specific technical facets

like image 3
ShayneR Avatar answered Nov 16 '22 04:11

ShayneR