【发布时间】:2021-11-26 10:14:18
【问题描述】:
我在 Spring Boot 项目中使用 QPID-JMS-Client(版本 0.59.0)。我想覆盖 netty 版本,因为这个版本的 QPID 带有 netty 版本:4.1.63.Final [1]。我想将netty版本覆盖到最新的:4.1.68.Final。 我还在我的 POM 中使用 spring-boot-starter-parent(版本:2.3.12.RELEASE)作为父 pom,它还附带一个 netty 版本(4.1.65.Final)。我知道 Spring Boot 版本相当旧,应该更新。无论如何,似乎 spring-boot-starter-parent 强制执行其 netty 版本。
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.12.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.example</groupId>
<artifactId>untitled1</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.qpid/qpid-jms-client -->
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-jms-client</artifactId>
<version>0.59.0</version>
</dependency>
</dependencies>
</project>
由于我没有使用任何 spring boot 依赖项,我不明白为什么 netty 版本设置为4.1.65.Final:
[INFO] --- maven-dependency-plugin:3.1.2:tree (default-cli) @ untitled1 ---
[INFO] org.example:untitled1:jar:1.0-SNAPSHOT
[INFO] \- org.apache.qpid:qpid-jms-client:jar:0.59.0:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] +- org.apache.geronimo.specs:geronimo-jms_2.0_spec:jar:1.0-alpha-2:compile
[INFO] +- org.apache.qpid:proton-j:jar:0.33.8:compile
[INFO] +- io.netty:netty-buffer:jar:4.1.65.Final:compile
[INFO] +- io.netty:netty-common:jar:4.1.65.Final:compile
[INFO] +- io.netty:netty-handler:jar:4.1.65.Final:compile
[INFO] | +- io.netty:netty-resolver:jar:4.1.65.Final:compile
[INFO] | \- io.netty:netty-codec:jar:4.1.65.Final:compile
[INFO] +- io.netty:netty-transport:jar:4.1.65.Final:compile
[INFO] +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.65.Final:compile
[INFO] | \- io.netty:netty-transport-native-unix-common:jar:4.1.65.Final:compile
[INFO] +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.65.Final:compile
[INFO] \- io.netty:netty-codec-http:jar:4.1.65.Final:compile
QPID-JMS-CLIENT 的 pom 通过属性 netty-version[3] 定义 netty 版本,而 spring boot 使用 netty.version。如果我覆盖了spring boot的属性,QPID的版本就会改变:
...
<properties>
<netty.version>4.1.68.Final</netty.version>
</properties>
...
如果我覆盖 QPID 的版本,则完全没有效果:
...
<properties>
<netty-version>4.1.68.Final</netty-version>
</properties>
...
所以我的问题是:
- 为什么 maven 强制执行父 poms netty 版本,而依赖项带有明确的不同版本? (即使我降低了 spring boots 版本,netty 依赖项也设置为该版本)
- 如何正确覆盖netty的版本?
问候
[1]https://mvnrepository.com/artifact/org.apache.qpid/qpid-jms-client/0.59.0
【问题讨论】:
-
使用更新版本的 Spring Boot(例如 2.5.5)..
-
当然,这是可能的,但我想了解为什么 maven 的行为如此。
标签: java spring-boot maven qpid spring-boot-starter-parent