在Spring Boot中,spring-boot-starter
模式上有一些罐子。所有这些罐子都不包含任何包装。它们的用途是什么?
在Maven POM中,添加了以下依赖项:
我真的需要在这些罐子里使用哪些Spring Boot罐子?我的项目没有任何依赖管理。我的项目是使用Spring Security的Spring MVC应用程序。
答案 0 :(得分:23)
这些依赖项旨在为具有所有所需依赖项的ad-hoc框架项目提供统一条目。
它们通常应该从您的项目描述符( pom.xml )继承,以便您获得具有已配置版本的所有父项依赖项。在开发者方面没有更多的负担:
Starter POM是一组方便的依赖项描述符,您可以在应用程序中包含这些描述符。您可以获得所需的所有Spring和相关技术的一站式服务,而无需搜索示例代码并复制粘贴的依赖描述符。例如,如果您想开始使用Spring和JPA进行数据库访问,只需在项目中包含spring-boot-starter-data-jpa依赖项,您就可以了。
参考, Spring Boot Starter POM 。
这些POM可用于合成可用于某种项目的依赖项,例如对于一个简单的Spring MVC项目,将包含以下工件(从 spring-boot-starter 读取, spring-boot-starter-web , spring- boot-starter-security 分别):
可以在maven central repository中无缝地导航搜索结果。
请注意,这可能不是一个完整的参考列表,因为某些组件可能正在混乱,因此工件可能会更新。
答案 1 :(得分:4)
简单地说,它们是依赖描述符,它列出了传递依赖关系,这些依赖关系是经过测试可以协同工作的版本,可以节省您将库放在一起处理应用程序某些方面的时间。
答案 2 :(得分:0)
您还可以使用以下命令让maven报告spring boot project pom.xml文件中定义的各种spring-boot-starter- *所需的依赖项
Assert.assertTrue(isElementPresent(By.xpath("//form[@class='section-filter__form']"));
例如使用spring 1.5.8.RELEASE,使用以下jar(和版本)
注意格式为Group Id:Artifact Id:Version:Scope
mvn dependency:resolve
只需忽略具有部署测试范围的jar。
如果您没有方便的弹簧启动项目,只需在Spring Initializr创建一个,使用您需要的任何弹簧启动启动器。它还使用maven wrapper,它包装了maven命令,节省了分别设置和安装maven的时间。
所以只需从Spring Initializr下载zip文件,解压缩并在解压缩的文件夹中打开命令提示符,然后使用以下命令
适用于Linux / Mac OS
The following files have been resolved:
com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
aopalliance:aopalliance:jar:1.0:compile
org.hamcrest:hamcrest-library:jar:1.3:test
org.mockito:mockito-core:jar:1.10.19:test
org.assertj:assertj-core:jar:2.6.0:test
org.springframework:spring-beans:jar:4.3.12.RELEASE:compile
org.springframework.boot:spring-boot-test:jar:1.5.8.RELEASE:test
org.springframework.boot:spring-boot-autoconfigure:jar:1.5.8.RELEASE:compile
org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.8.RELEASE:compile
org.skyscreamer:jsonassert:jar:1.4.0:test
org.yaml:snakeyaml:jar:1.17:runtime
com.fasterxml:classmate:jar:1.3.4:compile
org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
org.springframework.boot:spring-boot-starter-test:jar:1.5.8.RELEASE:test
org.hamcrest:hamcrest-core:jar:1.3:test
com.jayway.jsonpath:json-path:jar:2.2.0:test
org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.23:compile
org.springframework.boot:spring-boot:jar:1.5.8.RELEASE:compile
org.apache.tomcat:tomcat-annotations-api:jar:8.5.23:compile
org.springframework:spring-context:jar:4.3.12.RELEASE:compile
org.hibernate:hibernate-validator:jar:5.3.5.Final:compile
javax.validation:validation-api:jar:1.1.0.Final:compile
org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.23:compile
org.springframework.boot:spring-boot-starter-logging:jar:1.5.8.RELEASE:compile
com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile
org.ow2.asm:asm:jar:5.0.3:test
org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.23:compile
org.slf4j:log4j-over-slf4j:jar:1.7.25:compile
org.springframework:spring-web:jar:4.3.12.RELEASE:compile
ch.qos.logback:logback-core:jar:1.1.11:compile
org.springframework.security:spring-security-core:jar:4.2.3.RELEASE:compile
org.springframework:spring-test:jar:4.3.12.RELEASE:test
org.springframework.boot:spring-boot-starter:jar:1.5.8.RELEASE:compile
org.springframework.security:spring-security-test:jar:4.2.3.RELEASE:test
org.springframework.boot:spring-boot-starter-web:jar:1.5.8.RELEASE:compile
org.springframework:spring-core:jar:4.3.12.RELEASE:compile
org.springframework.boot:spring-boot-starter-security:jar:1.5.8.RELEASE:compile
org.springframework.boot:spring-boot-actuator:jar:1.5.8.RELEASE:compile
org.objenesis:objenesis:jar:2.1:test
org.springframework:spring-expression:jar:4.3.12.RELEASE:compile
org.springframework.boot:spring-boot-starter-actuator:jar:1.5.8.RELEASE:compile
org.springframework.security:spring-security-config:jar:4.2.3.RELEASE:compile
org.springframework.security:spring-security-web:jar:4.2.3.RELEASE:compile
org.springframework:spring-aop:jar:4.3.12.RELEASE:compile
junit:junit:jar:4.12:test
org.slf4j:slf4j-api:jar:1.7.25:compile
net.minidev:json-smart:jar:2.2.1:test
org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.8.RELEASE:test
net.minidev:accessors-smart:jar:1.1:test
org.springframework:spring-webmvc:jar:4.3.12.RELEASE:compile
ch.qos.logback:logback-classic:jar:1.1.11:compile
org.slf4j:jul-to-slf4j:jar:1.7.25:compile
com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile
对于Windows
./mvnw dependency:resolve