如何在 Windows 上修复 Maven 中的 'Missing requirement' 错误

How to fix 'Missing requirement' error in Maven on Windows

我正在尝试构建 dbeaver 并在 运行 mvn package 时出现以下错误:

[ERROR] Cannot resolve project dependencies:
[ERROR]   Software being installed: org.jkiss.dbeaver.slf4j 1.0.0.qualifier
[ERROR]   Missing requirement: org.jkiss.dbeaver.slf4j 1.0.0.qualifier requires 'bundle org.slf4j.api 0.0.0' but it could not be found

我 运行 在 Windows 10 上使用 apache-maven-3.6.1。奇怪的是,当我在 Linux 上尝试相同的步骤时,它构建没有问题。

更新

可能的原因是 maven 3.6.1 https://www.eclipse.org/lists/tycho-user/msg08177.html

原版post

我认为这里的问题是 https://dbeaver.io/eclipse-repo/ p2 站点缺少 slf4j 包并且 Tycho (?) 无法解决需求。我仍然不知道如何使独立的 maven 构建工作,但这里有一个关于如何使用 Eclipse(和嵌入式 maven)构建 Windows 二进制文件的丑陋解决方法。

您可以使用 p2-maven-plugin 自行构建缺少的包。您可以临时修改 product\localRepository\pom.xml 以拥有像

这样的单个工件,而不是设置一个全新的项目
...
<artifacts>
  <artifact><id>org.slf4j:slf4j-api:1.7.26</id></artifact>
</artifacts>
...

现在构建那个 (product\localRepository\) 项目并启动码头

mvn p2:site
start mvn jetty:start

现在 您可以将这个临时更新站点 (http://localhost:8080/site/) 添加到您的 Eclipse 安装中(帮助 -> 安装新软件)并安装 slf4j。您应该已经能够从 Eclipse 中 运行 DBeaver。

要构建二进制文件, 将此临时存储库添加到主 pom.xml 文件中,例如在 local-contrib 之后。

    <repository>
        <id>more</id>
        <url>http://localhost:8080/site/</url>
        <layout>p2</layout>
    </repository>

然后转到运行 Configurations -> Maven Build -> dbeaver,输入package goal 并勾选Skip Tests,点击运行然后去喝杯咖啡。

如您所见,Eclipse 使用某种嵌入式 maven 运行time,所以我猜它解决问题的方式不同。

注意 如果您要更新本地 git 存储库,您可能需要大量更新 Eclipse 项目。我无法通过右键单击项目 -> 配置 -> 配置和检测嵌套项目来做到这一点 :( 但是删除 Eclipse 项目和嵌套项目(不删除底层文件)和 re-importing Maven 项目对我有用.

这个 https://github.com/dbeaver/dbeaver/issues/6115 也有一个未解决的问题。