gpt4 book ai didi

java - POM中有没有办法为依赖包指定更高版本?

转载 作者:行者123 更新时间:2023-12-02 09:02:48 25 4
gpt4 key购买 nike

我正在使用 Maven 在我的应用程序中设置依赖项。

我正在使用 Spring Boot v2.1.12.RELEASE,它引入了 Spring Core v5.1.13

但是还有一个 Spring Integration 库 v5.1.9(最新的)并带来了 Spring Core v5.1.11.RELEASE

正如您所看到的,我希望 Spring Integration 不解析为 Spring Core 的 v5.1.11,因为它存在一些漏洞。

有没有办法在POM中指定Spring Integration解析为Spring Core的5.1.13(而不是5.1.11 )?

    <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.12.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>5.1.9</version>
</dependency>

P.S 我不想升级到最新版本的 Spring Boot。

最佳答案

使用maven排除标签排除传递依赖,确保排除的库直接添加到pom中或者被其他依赖拉入。

<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>5.1.9</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.1.11.RELEASE</version>
</exclusion>
</exclusions>
</dependency>

免责声明:这只是满足您当前需求的解决方案,仅当没有其他选项可用时才使用它,因为从长远来看,我们自己管理 spring 管理的依赖项是不可维护的。

关于java - POM中有没有办法为依赖包指定更高版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60038401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com