导入示例时Eclipse项目中的ArtifactTransferException

时间:2023-01-18 22:06:40

I'm trying to run some of the Netty example projects. After importing the Maven project, Eclipse reports the following problem:

我正在尝试运行一些Netty示例项目。导入Maven项目后,Eclipse报告以下问题:

ArtifactTransferException: Could not transfer artifact io.netty:netty-tcnative:jar:${os.detected.classifier}:1.1.33.Fork2 from/to central (http://repo1.maven.org/maven2): Illegal character in path at index 96: http://repo1.maven.org/maven2/io/netty/netty-tcnative/1.1.33.Fork2/netty-tcnative-1.1.33.Fork2-${os.detected.classifier}.jar

Things I've tried after researching related questions:

在研究相关问题后我尝试过的事情:

  • Deleting the lastupdated files (seems to be a common cause of ArtifactTransferExceptions)
  • 删除lastupdated文件(似乎是ArtifactTransferExceptions的常见原因)

  • Manually adding the os-maven-plugin to the eclipse plugins folder as described here
  • 手动将os-maven-plugin添加到eclipse插件文件夹中,如此处所述

  • Cleaning the project
  • 清洁项目

  • Deleting the eclipse project and re-importing
  • 删除eclipse项目并重新导入

What should I try next (or am I even going down the right path for running the Netty examples)?

接下来我应该尝试什么(或者我是否正在沿着正确的道路运行Netty示例)?

4 个解决方案

#1


I think there is an issue with the os-maven-plugin and your eclipse installation. The solution is to manually add the os-maven-plugin to the eclipse plugins folder. In your question you wrote that you have done this. However, in your case I think that eclipse is still not able to run the os-maven-plugin. Therefore, I suggest to try again to move the os-maven-plugin to the eclipse plugins folder.

我认为os-maven-plugin和你的eclipse安装存在问题。解决方案是手动将os-maven-plugin添加到eclipse插件文件夹中。在你的问题中你写道你已经完成了这个。但是,在你的情况下,我认为eclipse仍然无法运行os-maven-plugin。因此,我建议再次尝试将os-maven-plugin移动到eclipse插件文件夹中。

In the problem report of eclipse you can find the property ${os.detected.classifier}. Eclipse can not transfer the artifact as this property is not evaluated. If you run mvn package the property is evaluated. Therefore, with mvn package the transfer and the build is successful.

在eclipse的问题报告中,您可以找到属性$ {os.detected.classifier}。 Eclipse无法传输工件,因为未评估此属性。如果运行mvn包,则会评估该属性。因此,使用mvn包,传输和构建是成功的。

The property ${os.detected.classifier} belongs to the os-maven-plugin that allows to use platform-dependent project propertes. Eclipse does not evaluate these expressions. According to the readme of the plugin you have to download the plugin as jar and put it into the <ECLIPSE_HOME>/plugins directory. In my case with the jar in my eclipse plugins directory I was able to successfully execute the pom file in eclipse.

属性$ {os.detected.classifier}属于os-maven-plugin,允许使用与平台相关的项目属性。 Eclipse不评估这些表达式。根据插件的自述文件,您必须将插件下载为jar并将其放入 / plugins目录中。在我的情况下使用我的eclipse插件目录中的jar,我能够在eclipse中成功执行pom文件。

#2


After manually adding the plugin to the plugins folder, adding this to the pom under < plugins > ... < /plugins> fixed the issue for me.

手动将插件添加到plugins文件夹后,将其添加到 ... 下的pom中为我解决了问题。

        <plugin>
            <groupId>kr.motd.maven</groupId>
            <artifactId>os-maven-plugin</artifactId>
        </plugin>

You can also right click on the pom.xml file from the Package Explorer -> Maven -> Add Plugin -> specify group ID and artifact ID.

您还可以右键单击Package Explorer - > Maven - > Add Plugin中的pom.xml文件 - >指定组ID和工件ID。

#3


you can use

您可以使用

mvn package -DskipTests

then it would print the message at the begining

然后它会在开头打印消息

[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: linux
[INFO] os.detected.arch: x86_64
[INFO] os.detected.classifier: linux-x86_64
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:

then stop the mvn command, as you already get the properties right value, stop the command or you can't find the message in too much printing, then add the following in the pom.xml file of parent project:

然后停止mvn命令,因为你已经获得了属性正确的值,停止了命令或者在打印过多时找不到该消息,然后在父项目的pom.xml文件中添加以下内容:

<properties>
    <os.detected.name>linux</os.detected.name>
    <os.detected.arch>x86_64</os.detected.arch>
    <os.detected.classifier>linux-x86_64</os.detected.classifier>
...

#4


I got the same issue. It was solved by adding:

我遇到了同样的问题。它通过添加:

<extensions>
    <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.4.0.Final</version>
    </extension>
</extensions>

inside the tag. Questions see here: https://github.com/trustin/os-maven-plugin

在标签内。问题见:https://github.com/trustin/os-maven-plugin

#1


I think there is an issue with the os-maven-plugin and your eclipse installation. The solution is to manually add the os-maven-plugin to the eclipse plugins folder. In your question you wrote that you have done this. However, in your case I think that eclipse is still not able to run the os-maven-plugin. Therefore, I suggest to try again to move the os-maven-plugin to the eclipse plugins folder.

我认为os-maven-plugin和你的eclipse安装存在问题。解决方案是手动将os-maven-plugin添加到eclipse插件文件夹中。在你的问题中你写道你已经完成了这个。但是,在你的情况下,我认为eclipse仍然无法运行os-maven-plugin。因此,我建议再次尝试将os-maven-plugin移动到eclipse插件文件夹中。

In the problem report of eclipse you can find the property ${os.detected.classifier}. Eclipse can not transfer the artifact as this property is not evaluated. If you run mvn package the property is evaluated. Therefore, with mvn package the transfer and the build is successful.

在eclipse的问题报告中,您可以找到属性$ {os.detected.classifier}。 Eclipse无法传输工件,因为未评估此属性。如果运行mvn包,则会评估该属性。因此,使用mvn包,传输和构建是成功的。

The property ${os.detected.classifier} belongs to the os-maven-plugin that allows to use platform-dependent project propertes. Eclipse does not evaluate these expressions. According to the readme of the plugin you have to download the plugin as jar and put it into the <ECLIPSE_HOME>/plugins directory. In my case with the jar in my eclipse plugins directory I was able to successfully execute the pom file in eclipse.

属性$ {os.detected.classifier}属于os-maven-plugin,允许使用与平台相关的项目属性。 Eclipse不评估这些表达式。根据插件的自述文件,您必须将插件下载为jar并将其放入 / plugins目录中。在我的情况下使用我的eclipse插件目录中的jar,我能够在eclipse中成功执行pom文件。

#2


After manually adding the plugin to the plugins folder, adding this to the pom under < plugins > ... < /plugins> fixed the issue for me.

手动将插件添加到plugins文件夹后,将其添加到 ... 下的pom中为我解决了问题。

        <plugin>
            <groupId>kr.motd.maven</groupId>
            <artifactId>os-maven-plugin</artifactId>
        </plugin>

You can also right click on the pom.xml file from the Package Explorer -> Maven -> Add Plugin -> specify group ID and artifact ID.

您还可以右键单击Package Explorer - > Maven - > Add Plugin中的pom.xml文件 - >指定组ID和工件ID。

#3


you can use

您可以使用

mvn package -DskipTests

then it would print the message at the begining

然后它会在开头打印消息

[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: linux
[INFO] os.detected.arch: x86_64
[INFO] os.detected.classifier: linux-x86_64
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:

then stop the mvn command, as you already get the properties right value, stop the command or you can't find the message in too much printing, then add the following in the pom.xml file of parent project:

然后停止mvn命令,因为你已经获得了属性正确的值,停止了命令或者在打印过多时找不到该消息,然后在父项目的pom.xml文件中添加以下内容:

<properties>
    <os.detected.name>linux</os.detected.name>
    <os.detected.arch>x86_64</os.detected.arch>
    <os.detected.classifier>linux-x86_64</os.detected.classifier>
...

#4


I got the same issue. It was solved by adding:

我遇到了同样的问题。它通过添加:

<extensions>
    <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.4.0.Final</version>
    </extension>
</extensions>

inside the tag. Questions see here: https://github.com/trustin/os-maven-plugin

在标签内。问题见:https://github.com/trustin/os-maven-plugin