java - 什么是 `spring-boot-starter` jar ?

标签 java spring maven spring-boot

在Spring Boot中,有一些关于spring-boot-starter模式的jar。所有这些 jar 不包含任何包。它们有什么用?

在 Maven POM 中,添加了以下依赖项:

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

我实际上需要哪些 Spring Boot jar 才能使用这些 jar 中的功能?我的项目没有任何依赖管理。我的项目是一个使用 Spring Security 的 Spring MVC 应用程序。

最佳答案

这些依赖项旨在为具有所有需要的依赖项的临时框架项目提供一个统一的入口。

它们通常应该从您的项目描述符 (pom.xml) 继承,以便您获得所有具有配置版本的父依赖项。开发者方面没有更多负担:

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.

引用, Spring Boot Starter POM .

编辑:

这些 POM 可用于合成可用于某种项目的依赖项,例如对于一个简单的 Spring MVC 项目,将包含以下 Artifact (从 spring-boot-starterspring-boot-starter-webspring- boot-starter-security 分别):

  • Spring Boot Artifact :
    • org.springframework.boot:spring-boot
    • org.springframework.boot:spring-boot-autoconfigure
    • org.springframework.boot:spring-boot-starter-logging
  • Spring Core、Web、MVC、安全 Artifact :
    • 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

可以在 maven central repository 中无缝导航搜索结果中找到 Artifact 。 .

请注意,这可能不是完整的引用列表,因为某些组件可能会丢失,因此 Artifact 可能会被更新。

关于java - 什么是 `spring-boot-starter` jar ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28273543/

相关文章:

java - 使用外部库 Spring Framework 通过模拟执行 Karate jar

java - SLF4J:类路径包含多个SLF4J绑定(bind);排除 slf4j

java - 使用 Swing (netbeans) 在 SMSlib sendmessage 上添加进度条

java - 桌面 SWING 应用程序上的 jpa

java - 如何坚持使用 Hibernate

java - Spring缓存不能与EHCache+JCache一起使用

spring - 我可以让自定义 Controller 镜像 Spring-Data-Rest/Spring-Hateoas 生成的类的格式吗?

java - 使用基本身份验证从 wsdl url 生成 java 类

java - 多个Spring Boot错误: package org. springframework.boot不存在

java - Flask/Pymongo 对 Java 的 JSON 响应