SpringBoot依赖管理特性详解
SpringBoot依赖管理特性
我们注意到,在项目的 pom.xml 配置文件中,引入的依赖 spring-boot-starter-web 并没有指定其版本号
而在 maven 依赖中却可以发现其版本号为 2.3.4.RELEASE,这说明 SpringBoot 自动帮我们引入了对应版本的依赖,那么在哪儿可以找到 SpringBoot 自动引入的依赖信息呢?
1.在pom.xml 配置文件中
按 ctrl 键同时鼠标点击 标签中 SpringBoot 依赖的 spring-boot-starter-parent(artifactId 标签),即可进入 spring-boot-starter-parent-2.3.4.RELEASE.pom 配置文件,发现文件上面也有一个父项目
2.按 ctrl 键同时鼠标点击 spring-boot-dependencies
即可进入 spring-boot-dependencies-2.3.4.RELEASE.pom 配置文件,我们发现下面有一个 配置项,里面有如下配置信息
<properties> <activemq.version>5.15.13</activemq.version> <antlr2.version>2.7.7</antlr2.version> <appengine-sdk.version>1.9.82</appengine-sdk.version> <artemis.version>2.12.0</artemis.version> <aspectj.version>1.9.6</aspectj.version> <assertj.version>3.16.1</assertj.version> <atomikos.version>4.0.6</atomikos.version> <awaitility.version>4.0.3</awaitility.version> <bitronix.version>2.1.4</bitronix.version> <build-helper-maven-plugin.version>3.1.0</build-helper-maven-plugin.version> <byte-buddy.version>1.10.14</byte-buddy.version> <caffeine.version>2.8.5</caffeine.version> <cassandra-driver.version>4.6.1</cassandra-driver.version> <classmate.version>1.5.1</classmate.version> <commons-codec.version>1.14</commons-codec.version> <commons-dbcp2.version>2.7.0</commons-dbcp2.version> <commons-lang3.version>3.10</commons-lang3.version> <commons-pool.version>1.6</commons-pool.version> <commons-pool2.version>2.8.1</commons-pool2.version> <couchbase-client.version>3.0.8</couchbase-client.version> <db2-jdbc.version>11.5.4.0</db2-jdbc.version> <dependency-management-plugin.version>1.0.10.RELEASE</dependency-management-plugin.version> <derby.version>10.14.2.0</derby.version> <dropwizard-metrics.version>4.1.12.1</dropwizard-metrics.version> <ehcache.version>2.10.6</ehcache.version> <ehcache3.version>3.8.1</ehcache3.version> <elasticsearch.version>7.6.2</elasticsearch.version> <embedded-mongo.version>2.2.0</embedded-mongo.version> <exec-maven-plugin.version>1.6.0</exec-maven-plugin.version> <flatten-maven-plugin.version>1.2.5</flatten-maven-plugin.version> <flyway.version>6.4.4</flyway.version> <freemarker.version>2.3.30</freemarker.version> <git-commit-id-plugin.version>3.0.1</git-commit-id-plugin.version> <glassfish-el.version>3.0.3</glassfish-el.version> <glassfish-jaxb.version>2.3.3</glassfish-jaxb.version> <groovy.version>2.5.13</groovy.version> <gson.version>2.8.6</gson.version> <h2.version>1.4.200</h2.version> <hamcrest.version>2.2</hamcrest.version> <hazelcast.version>3.12.9</hazelcast.version> <hazelcast-hibernate5.version>1.3.2</hazelcast-hibernate5.version> <hibernate.version>5.4.21.Final</hibernate.version> <hibernate-validator.version>6.1.5.Final</hibernate-validator.version> <hikaricp.version>3.4.5</hikaricp.version> <hsqldb.version>2.5.1</hsqldb.version> <htmlunit.version>2.40.0</htmlunit.version> <httpasyncclient.version>4.1.4</httpasyncclient.version> <httpclient.version>4.5.12</httpclient.version> <httpcore.version>4.4.13</httpcore.version> <infinispan.version>10.1.8.Final</infinispan.version> <influxdb-java.version>2.18</influxdb-java.version> <jackson-bom.version>2.11.2</jackson-bom.version> <jakarta-activation.version>1.2.2</jakarta-activation.version> <jakarta-annotation.version>1.3.5</jakarta-annotation.version> <jakarta-jms.version>2.0.3</jakarta-jms.version> <jakarta-json.version>1.1.6</jakarta-json.version> <jakarta-json-bind.version>1.0.2</jakarta-json-bind.version> <jakarta-mail.version>1.6.5</jakarta-mail.version> <jakarta-persistence.version>2.2.3</jakarta-persistence.version> <jakarta-servlet.version>4.0.4</jakarta-servlet.version> <jakarta-servlet-jsp-jstl.version>1.2.7</jakarta-servlet-jsp-jstl.version> <jakarta-transaction.version>1.3.3</jakarta-transaction.version> <jakarta-validation.version>2.0.2</jakarta-validation.version> <jakarta-websocket.version>1.1.2</jakarta-websocket.version> <jakarta-ws-rs.version>2.1.6</jakarta-ws-rs.version> <jakarta-xml-bind.version>2.3.3</jakarta-xml-bind.version> <jakarta-xml-soap.version>1.4.2</jakarta-xml-soap.version> <jakarta-xml-ws.version>2.3.3</jakarta-xml-ws.version> <janino.version>3.1.2</janino.version> <javax-activation.version>1.2.0</javax-activation.version> <javax-annotation.version>1.3.2</javax-annotation.version> <javax-cache.version>1.1.1</javax-cache.version> <javax-jaxb.version>2.3.1</javax-jaxb.version> <javax-jaxws.version>2.3.1</javax-jaxws.version> <javax-jms.version>2.0.1</javax-jms.version> <javax-json.version>1.1.4</javax-json.version> <javax-jsonb.version>1.0</javax-jsonb.version> <javax-mail.version>1.6.2</javax-mail.version> <javax-money.version>1.0.3</javax-money.version> <javax-persistence.version>2.2</javax-persistence.version> <javax-transaction.version>1.3</javax-transaction.version> <javax-validation.version>2.0.1.Final</javax-validation.version> <javax-websocket.version>1.1</javax-websocket.version> <jaxen.version>1.2.0</jaxen.version> <jaybird.version>3.0.9</jaybird.version> <jboss-logging.version>3.4.1.Final</jboss-logging.version> <jboss-transaction-spi.version>7.6.0.Final</jboss-transaction-spi.version> <jdom2.version>2.0.6</jdom2.version> <jedis.version>3.3.0</jedis.version> <jersey.version>2.30.1</jersey.version> <jetty-el.version>8.5.54</jetty-el.version> <jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version> <jetty-reactive-httpclient.version>1.1.4</jetty-reactive-httpclient.version> <jetty.version>9.4.31.v20200723</jetty.version> <jmustache.version>1.15</jmustache.version> <johnzon.version>1.2.8</johnzon.version> <jolokia.version>1.6.2</jolokia.version> <jooq.version>3.13.4</jooq.version> <json-path.version>2.4.0</json-path.version> <json-smart.version>2.3</json-smart.version> <jsonassert.version>1.5.0</jsonassert.version> <jstl.version>1.2</jstl.version> <jtds.version>1.3.1</jtds.version> <junit.version>4.13</junit.version> <junit-jupiter.version>5.6.2</junit-jupiter.version> <kafka.version>2.5.1</kafka.version> <kotlin.version>1.3.72</kotlin.version> <kotlin-coroutines.version>1.3.8</kotlin-coroutines.version> <lettuce.version>5.3.4.RELEASE</lettuce.version> <liquibase.version>3.8.9</liquibase.version> <log4j2.version>2.13.3</log4j2.version> <logback.version>1.2.3</logback.version> <lombok.version>1.18.12</lombok.version> <mariadb.version>2.6.2</mariadb.version> <maven-antrun-plugin.version>1.8</maven-antrun-plugin.version> <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version> <maven-clean-plugin.version>3.1.0</maven-clean-plugin.version> <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version> <maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version> <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version> <maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version> <maven-failsafe-plugin.version>2.22.2</maven-failsafe-plugin.version> <maven-help-plugin.version>3.2.0</maven-help-plugin.version> <maven-install-plugin.version>2.5.2</maven-install-plugin.version> <maven-invoker-plugin.version>3.2.1</maven-invoker-plugin.version> <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version> <maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version> <maven-resources-plugin.version>3.1.0</maven-resources-plugin.version> <maven-shade-plugin.version>3.2.4</maven-shade-plugin.version> <maven-source-plugin.version>3.2.1</maven-source-plugin.version> <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version> <maven-war-plugin.version>3.2.3</maven-war-plugin.version> <micrometer.version>1.5.5</micrometer.version> <mimepull.version>1.9.13</mimepull.version> <mockito.version>3.3.3</mockito.version> <mongodb.version>4.0.5</mongodb.version> <mssql-jdbc.version>7.4.1.jre8</mssql-jdbc.version> <mysql.version>8.0.21</mysql.version> <nekohtml.version>1.9.22</nekohtml.version> <neo4j-ogm.version>3.2.16</neo4j-ogm.version> <netty.version>4.1.52.Final</netty.version> <netty-tcnative.version>2.0.34.Final</netty-tcnative.version> <nio-multipart-parser.version>1.1.0</nio-multipart-parser.version> <oauth2-oidc-sdk.version>7.1.1</oauth2-oidc-sdk.version> <nimbus-jose-jwt.version>8.19</nimbus-jose-jwt.version> <ojdbc.version>19.3.0.0</ojdbc.version> <okhttp3.version>3.14.9</okhttp3.version> <oracle-database.version>19.3.0.0</oracle-database.version> <pooled-jms.version>1.1.2</pooled-jms.version> <postgresql.version>42.2.16</postgresql.version> <prometheus-pushgateway.version>0.9.0</prometheus-pushgateway.version> <quartz.version>2.3.2</quartz.version> <querydsl.version>4.3.1</querydsl.version> <r2dbc-bom.version>Arabba-SR7</r2dbc-bom.version> <rabbit-amqp-client.version>5.9.0</rabbit-amqp-client.version> <reactive-streams.version>1.0.3</reactive-streams.version> <reactor-bom.version>Dysprosium-SR12</reactor-bom.version> <rest-assured.version>3.3.0</rest-assured.version> <rsocket.version>1.0.2</rsocket.version> <rxjava.version>1.3.8</rxjava.version> <rxjava-adapter.version>1.2.1</rxjava-adapter.version> <rxjava2.version>2.2.19</rxjava2.version> <saaj-impl.version>1.5.2</saaj-impl.version> <selenium.version>3.141.59</selenium.version> <selenium-htmlunit.version>2.40.0</selenium-htmlunit.version> <sendgrid.version>4.4.8</sendgrid.version> <servlet-api.version>4.0.1</servlet-api.version> <slf4j.version>1.7.30</slf4j.version> <snakeyaml.version>1.26</snakeyaml.version> <solr.version>8.5.2</solr.version> <spring-amqp.version>2.2.11.RELEASE</spring-amqp.version> <spring-batch.version>4.2.4.RELEASE</spring-batch.version> <spring-data-releasetrain.version>Neumann-SR4</spring-data-releasetrain.version> <spring-framework.version>5.2.9.RELEASE</spring-framework.version> <spring-hateoas.version>1.1.2.RELEASE</spring-hateoas.version> <spring-integration.version>5.3.2.RELEASE</spring-integration.version> <spring-kafka.version>2.5.6.RELEASE</spring-kafka.version> <spring-ldap.version>2.3.3.RELEASE</spring-ldap.version> <spring-restdocs.version>2.0.5.RELEASE</spring-restdocs.version> <spring-retry.version>1.2.5.RELEASE</spring-retry.version> <spring-security.version>5.3.4.RELEASE</spring-security.version> <spring-session-bom.version>Dragonfruit-SR1</spring-session-bom.version> <spring-ws.version>3.0.10.RELEASE</spring-ws.version> <sqlite-jdbc.version>3.31.1</sqlite-jdbc.version> <sun-mail.version>1.6.5</sun-mail.version> <thymeleaf.version>3.0.11.RELEASE</thymeleaf.version> <thymeleaf-extras-data-attribute.version>2.0.1</thymeleaf-extras-data-attribute.version> <thymeleaf-extras-java8time.version>3.0.4.RELEASE</thymeleaf-extras-java8time.version> <thymeleaf-extras-springsecurity.version>3.0.4.RELEASE</thymeleaf-extras-springsecurity.version> <thymeleaf-layout-dialect.version>2.4.1</thymeleaf-layout-dialect.version> <tomcat.version>9.0.38</tomcat.version> <unboundid-ldapsdk.version>4.0.14</unboundid-ldapsdk.version> <undertow.version>2.1.4.Final</undertow.version> <versions-maven-plugin.version>2.7</versions-maven-plugin.version> <webjars-hal-browser.version>3325375</webjars-hal-browser.version> <webjars-locator-core.version>0.45</webjars-locator-core.version> <wsdl4j.version>1.6.3</wsdl4j.version> <xml-maven-plugin.version>1.0.2</xml-maven-plugin.version> <xmlunit2.version>2.7.0</xmlunit2.version> </properties>
这里面已经声明了我们开发中可能会遇到的所有的依赖版本信息;
这说明只要我们在开发 SpringBoot 项目的时候引入了父级依赖 spring-boot-starter-parent,其余对应的常用依赖的版本无需关心;
这叫做 SpringBoot 版本依赖自动仲裁机制
3.如果我们要修改SpringBoot 自动仲裁的依赖版本
例如:lombok 的版本,我们在 spring-boot-dependencies-2.3.4.RELEASE.pom 配置文件中可以看到其版本为:1.18.12
那么我们只需要在自己项目的 pom.xml 配置文件中,添加 配置项,覆盖 lombok.version 即可
然后在 pom.xml 配置文件中右键 Maven -> Reimport 刷新依赖即可;最终效果如下
注意:在 pom.xml 配置文件中 标签下添加的对应依赖版本的标签要和 spring-boot-dependencies-2.3.4.RELEASE.pom 中 配置下的版本的标签相同
4.未来在开发过程中
- 我们会使用到很多其他的 starter,官方的 starter 命名格式为:spring-boot-starter-xxx;
- 只要引入 starter,对应这个 starter 关联的依赖都会自动引入;
- 三方开发的 starter 命名格式为:xxx-spring-boot-starer;
官方所有的 starter 在官网:https://docs.spring.io/spring-boot/docs/2.3.4.RELEASE/reference/html/using-spring-boot.html#using-boot-starter 下找到
5.所有场景启动器最底层的依赖
是spring-boot-starter 依赖,该依赖在 spring-boot-starter-web-2.3.4.RELEASE.pom 中
总结
引入的依赖默认可以不添加版本号,除非引入的是非版本仲裁的依赖才需要指定版本号
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
jenkins如何通过pipeline部署springboot项目
为了提高SpringBoot项目的部署效率和规范性,建议将项目代码和部署脚本分离,项目代码仓库专注业务逻辑,构建为jar包;另外设立独立代码仓库存放Jenkinsfile等部署配置文件,在Jenkins中配置pipeline,自动拉取项目代码进行构建和部署2024-09-09浅谈@FeignClient中name和value属性的区别
这篇文章主要介绍了@FeignClient中name和value属性的区别,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2022-07-07使用Java的方式模拟Flutter的Widget实现多层括号嵌套
这篇文章主要介绍了使用Java的方式模拟Flutter的Widget的实现多层括号嵌套问题,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下2019-07-07
最新评论