在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应用程序 .
3 回答
简单地说,它们是依赖描述符,它们列出了传递依赖关系,这些转换依赖关系与经过测试的版本一起工作,以节省您尝试将库放在一起以处理应用程序的某些方面的时间 .
这些依赖项旨在为所有 needed dependencies 提供一个ad-hoc框架项目的统一条目 .
它们通常应该从您的项目描述符(pom.xml)继承,以便您获得具有已配置版本的所有父依赖项 . 在开发者方面没有更多的负担:
参考, Spring Boot Starter POM .
编辑:
这些POM可用于合成可用于某种项目的依赖项,例如,对于一个简单的Spring MVC项目,将包含以下工件(分别从spring-boot-starter,spring-boot-starter-web,spring-boot-starter-security中读取):
Spring Boot工件:
org.springframework.boot:spring-boot
org.springframework.boot:spring-boot-autoconfigure
org.springframework.boot:spring-boot-starter-logging
Spring Core,Web,MVC,安全工件:
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中无缝地导航搜索结果 .
请注意,这可能不是完整的参考列表,因为某些组件可能正在处理,因此工件可能会更新 .
您还可以使用以下命令来报告spring boot project pom.xml文件中定义的各种spring-boot-starter- *所需的依赖项 .
例如,使用spring 1.5.8.RELEASE,使用以下jar(和版本)
注释格式为Group Id:Artifact Id:Version:Scope
只需忽略具有部署测试范围的jar .
如果您没有方便的 spring 启动项目,只需在Spring Initializr创建一个,使用您需要的任何 spring 启动启动器 . 它还使用maven wrapper,它包装了maven命令,节省了分别设置和安装maven的时间 .
所以只需从Spring Initializr下载zip文件,解压缩并在解压缩文件夹中打开命令提示符,然后使用以下命令代替
适用于Linux / Mac OS
对于窗户