Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
174 views
in Technique[技术] by (71.8m points)

java - What are `spring-boot-starter` jars?

In Spring Boot, there are some jars on the pattern of spring-boot-starter. All these jars do not contain any packages. What is their use?

In Maven POMs, the following dependencies are added:

  • org.springframework.boot:spring-boot-starter-web
  • org.springframework.boot:spring-boot-starter-actuator
  • org.springframework.boot:spring-boot-starter-security

Which Spring Boot jars do I actually need to use the functionality in these jars? My project does not have any dependency management. My project is a Spring MVC application which uses Spring Security.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Those dependencies are meant to provide a unified entry to an ad-hoc skeleton project with all needed dependencies.

They should usually be inherited from your project descriptor (pom.xml) so that you get all parent dependecies with configured versions. No more burden to be done on the developer side:

Starter POMs are a set of convenient dependency descriptors that you can include in your application. You get a one-stop-shop for all the Spring and related technology that you need, without having to hunt through sample code and copy paste loads of dependency descriptors. 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.

Reference, Spring Boot Starter POM.

Edit:

Those POMs can be used to synthesize the dependencies that can be used for a certain kind of project, e.g. for a simple Spring MVC project, the following artifacts are to be included (Read from spring-boot-starter, spring-boot-starter-web, spring-boot-starter-security respectively):

  • Spring Boot artifacts:
    • org.springframework.boot:spring-boot
    • org.springframework.boot:spring-boot-autoconfigure
    • org.springframework.boot:spring-boot-starter-logging
  • Spring Core, Web, MVC, Security artifacts:
    • org.springframework:spring-core
    • org.springframework:spring-web
    • org.springframework:spring-webmvc
    • org.springframework:spring-beans
    • org.springframework:spring-context
    • org.springframework:spring-expression
    • org.springframework:spring-aop
    • org.springframework.security:spring-security-config
    • org.springframework.security:spring-security-web
    • org.hibernate:hibernate-validator
    • com.fasterxml.jackson.core:jackson-databind

The artifacts can be found seamlessly navigating search results in the maven central repository.

Note that this may not be a full fledged reference list as some components may be mising thus the artifacts are subject to be updated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...