首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >什么是“弹簧-启动-启动”罐子?

什么是“弹簧-启动-启动”罐子?
EN

Stack Overflow用户
提问于 2015-02-02 08:20:32
回答 3查看 38.3K关注 0票数 51

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

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

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

我实际上需要在这些jars中使用哪个Spring?我的项目没有任何依赖关系管理。我的项目是一个使用Security的Spring应用程序。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-02-02 08:28:54

这些依赖项的目的是提供一个统一的条目到一个具有所有所需的依赖项()的临时框架项目。

它们通常应该从您的项目描述符(pom.xml)中继承,这样您就可以得到所有具有配置版本的父依赖关系。开发人员无需再承担任何负担:

Starter是一组方便的依赖描述符,您可以在应用程序中包含这些描述符。您可以为您需要的所有Spring和相关技术提供一站式服务,而无需搜索示例代码并复制大量依赖项描述符。例如,如果您想开始使用Spring和JPA进行数据库访问,只需在您的项目中包含spring started jpa依赖项,就可以了。

参考资料,http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-starter-poms

编辑:

这些POMs可用于合成可用于某种项目的依赖项,例如对于一个简单的Spring项目,将包括以下构件(分别从spring-boot-starter、spring starter、spring starter security中读取):

  • Spring工件:
    • 启动:spring-boot
    • org.springframework.boot:spring-boot-autoconfigure
    • org.springframework.boot:spring-boot-starter-logging

  • Spring,Web,安全工件:
    • core.spring框架:spring-core
    • Org.Spring框架:spring
    • Org.Spring框架:spring
    • Org.Spring框架:spring
    • Org.Spring框架:spring-上下文
    • Org.Spring框架:spring-表达式
    • Org.Spring框架:spring
    • org.springframework.security:spring-security-config
    • org.springframework.security:spring-security-web
    • Org.Hibernate:hibernate-验证器
    • Konson.core:jackson-databind

这些工件可以在maven中央存储库中无缝地导航搜索结果。

请注意,这可能不是一个完整的引用列表,因为某些组件可能正在丢失,因此工件将被更新。

票数 26
EN

Stack Overflow用户

发布于 2017-01-03 12:11:12

简单地说,它们是一个依赖描述符,它将传递依赖项与经过测试的版本放在一起使用,以节省您的时间,使您不必试图将处理应用程序某些方面的库放在一起。

票数 4
EN

Stack Overflow用户

发布于 2017-10-26 09:47:01

您还可以使用以下命令,让maven报告spring启动项目pom.xml文件中定义的各个spring*所需的依赖项

代码语言:javascript
复制
mvn dependency:resolve

例如,在Spring1.5.8中,使用了以下jars (和版本)

注格式为组Id:工件Id:版本:范围

代码语言:javascript
复制
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

只需忽略具有部署测试范围的jars即可。

如果您手头没有spring启动项目,只需在弹簧起爆上创建一个,就可以使用您需要的任何spring引导启动程序。它还使用maven包装器,它封装了maven命令,可以节省您分别设置和安装maven的时间。

因此,只需从下载zip文件,解压缩并在解压缩文件夹中打开命令提示符,然后使用以下命令

用于Linux/Mac操作系统

代码语言:javascript
复制
 ./mvnw dependency:resolve

适用于窗户

代码语言:javascript
复制
 ./mvnw.cmd dependency:resolve
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28273543

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档