【问题标题】:How to totally overwrite the version of spring boot starter?如何完全覆盖spring boot starter的版本?
【发布时间】:2021-08-12 10:22:37
【问题描述】:

我父模块中的spring boot版本是v2.1.17.RELEASE

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

然后我在子模块中引入了spring-boot-starter-security,指定版本为2.4.4,覆盖了父模块中的版本(v2.1.17.RELEASE)。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
    <version>2.4.4</version>
</dependency>

然后,我运行mvn dependency:tree命令,发现子模块中spring-boot-starter-security的版本确实是2.4.4,但是中引用的artifactId(如spring-aop)的版本spring-boot-starter-security 仍然是 5.1.x 版本,它对应于 spring-boot-starter-security 的 v2.1.17.RELEASE 版本,而不是对应于 v2.4.4 版本的 spring-boot 的 5.3.x 版本-starter-安全

【问题讨论】:

    标签: spring spring-boot maven spring-security spring-boot-starter


    【解决方案1】:

    您好,请查看此示例

    <properties>
        <dependencies.version>2.1.17.RELEASE</dependencies.version>
        <security.version>2.4.4</security.version>
    </properties>
    <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-dependencies</artifactId>
          <version>${dependencies.version}</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
        <version>${security.version}</version>
    </dependency>
      </dependencies>
    </dependencyManagement>
    

    【讨论】:

    • 我试过了,但是没有用。 spring-boot-starter-security的版本确实是2.4.4,但是spring-security-web、spring-security-core等artifactId的版本不对(5.1.x)。
    猜你喜欢
    • 2018-03-27
    • 2022-01-19
    • 2017-12-18
    • 2021-01-12
    • 1970-01-01
    • 2015-09-20
    • 2021-07-08
    • 1970-01-01
    • 2017-01-29
    相关资源
    最近更新 更多