java在docker中运行springboot应用程序时忽略可选的reactorextra maven依赖项
我有一个Spring Boot应用程序,我使用docker compose在docker容器中运行。 我最近在pom中添加了reactor额外依赖项。由于某种原因,我不能再启动容器了
以下是我在pom中添加的内容:
<dependency>
<groupId>io.projectreactor.addons</groupId>
<artifactId>reactor-extra</artifactId>
<version>3.4.2</version>
</dependency>
现在,每当我尝试启动容器时,都会出现以下错误:
Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline (default-cli) on project backend: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact org.eclipse.swt:org.eclipse.swt.gtk.linux.x86_64:jar:4.5.2 in central
当我直接在intellij上运行代码时,代码运行良好,显然没有依赖性问题
我在这里看了一眼:https://mvnrepository.com/artifact/io.projectreactor.addons/reactor-extra/3.4.2
看起来这个“4.5.2”版本的org。日食swt。gtk。linux。x86_64不存在。我假设这在intellij上有效,因为这是一个可选的依赖项,但容器构建过程在尝试下载该版本时失败
我试着这样排除它:
<dependency>
<groupId>io.projectreactor.addons</groupId>
<artifactId>reactor-extra</artifactId>
<version>3.4.2</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
</exclusion>
</exclusions>
</dependency>
但它仍在尝试下载它,我得到了导致构建失败的相同错误
我还尝试添加org的现有4.3版本。日食swt。gtk。linux。x86_64到我的pom,但我仍然得到相同的结果
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
<version>4.3</version>
</dependency>
<dependency>
<groupId>io.projectreactor.addons</groupId>
<artifactId>reactor-extra</artifactId>
<version>3.4.2</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
</exclusion>
</exclusions>
</dependency>
如何防止maven尝试下载该依赖项
# 1 楼答案
我通过将此添加到我的pom中来修复它:
资料来源:
无法解决可选依赖项时脱机失败 https://issues.apache.org/jira/browse/MDEP-690
“正在运行org.apache.maven.plugins:maven依赖插件:3.1.1:此项目通过后脱机。对于版本3.1.2,目标失败,原因如下:”