【问题标题】:Springboot 3 dependencies not inherited未继承 Spring Boot 3 依赖项
【发布时间】:2022-12-22 18:37:30
【问题描述】:

我从 spring boot 2.7.6 升级到 spring boot 3.0.0;我有一个基于 maven 的多模块项目

在我的主模块中,我有:

<dependencyManagement>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-dependencies</artifactId>
      <version>3.0.0</version>
      <type>pom</type>
      <scope>import</scope>
   </dependency>
</dependencyManagement>

在我的模块之一中,我需要使用 jaxb。所以我在我的模块中添加了以下内容:

<dependency>
   <groupId>org.glassfish.jaxb</groupId>
   <artifactId>jaxb-runtime</artifactId>
</dependency>

据我所知,通过在我的子模块中阅读此处https://docs.spring.io/spring-boot/docs/3.0.0/reference/htmlsingle/#appendix.dependency-versions,我应该拥有 jaxb-runtime 的 4.0.1 版,但是通过查看依赖树,我看到了 2.3.5 版。任何的想法?

总是和这个有关,好像有些库不是子模块继承的。 在我的 Maven dependencyManagement 标签中,我必须添加:

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-oauth2-client</artifactId>
    <version>6.0.0</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>4.0.1</version>
</dependency>
<dependency>
    <groupId>org.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>3.10.8</version>
</dependency>
<dependency>
    <groupId>jakarta.validation</groupId>
    <artifactId>jakarta.validation-api</artifactId>
    <version>3.0.2</version>
</dependency>

使用以前版本的 springboot (2.7.6) 一切都很好,我不必添加任何以前的依赖项。都是spring boot bom继承的

你有什么提示或建议吗?

谢谢

安吉洛

更新 Maven 版本

这是我的环境:

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /home/angelo/apache-maven
Java version: 17.0.1, vendor: Oracle Corporation, runtime: /usr/lib/jvm/jdk-17.0.1
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-56-generic", arch: "amd64", family: "unix"

【问题讨论】:

  • 首先检查简单的事情...您是否记得在更改为使用更新的 Spring Boot 后mvn clean install 父 POM?
  • 当你不强制版本为 4.0.1 时查看依赖树:你会看到其他依赖首先拉取 2.3.5。当我需要了解已解决的依赖版本时,我喜欢 Eclipse“依赖层次结构”选项卡的 Maven 插件。 (第一个评论很聪明,还可以在您的 IDE 中“刷新”maven 项目以强制它加载新的依赖项)
  • @user944849 我总是从顶部执行全新安装
  • @ch4mp 我在 intellij 中使用了一个类似的插件;老实说,我直接添加了依赖项(在 dependencyManagement 中“强制”之前),我不明白是谁在加载 2.3.5,但它似乎是由 springboot 派生的
  • 这就是我对 eclipse 插件的看法:我不必“理解”,我只是“阅读”依赖关系是如何解决的

标签: spring-boot maven


【解决方案1】:

我认为您需要仔细检查您的依赖项。如果这些版本由 Spring Boot 依赖管理管理,则应尽可能避免使用 &lt;version&gt; 标记。

在你的情况下,我认为 your ehcache dependency is missing the jakarta classifier

<dependency>
  <groupId>org.ehcache</groupId>
  <artifactId>ehcache</artifactId>
  <classifier>jakarta</classifier>
</dependency>

【讨论】:

    猜你喜欢
    • 2016-06-10
    • 2017-10-30
    • 2015-12-20
    • 2015-08-02
    • 2018-05-01
    • 2020-03-31
    • 2020-11-11
    • 2018-01-10
    • 1970-01-01
    相关资源
    最近更新 更多