Maven无法在将依赖项添加到pom.xml后找到nd4j .jar文件。

huangapple go评论68阅读模式
英文:

why can't Maven find the nd4j .jar file after adding the dependency to pom.xml?

问题

我在IntelliJ IDEA中用OpenJDK-20创建了一个Maven程序,将nd4j的依赖项放在pom.xml文件的dependencies部分,并导入了nd4j.*。但是当我运行程序时,出现了以下错误:

在 central (https://repo.maven.apache.org/maven2) 中找不到 artifact org.nd4j:nd4j:jar:1.0.0-M2.1

我尝试过“使用 -U 运行Maven导入”,这是编译器说可以修复错误的方法,但仍然出现相同的错误。我还访问了repo.maven.apache.org网站,但那里没有nd4j。

英文:

I created a maven program in intellij-idea with openjdk-20, and I put the dependency for nd4j in the dependencies section in pom.xml, and imported nd4j.*, but when I ran the program, it raised this error:

Could not find artifact org.nd4j:nd4j:jar:1.0.0-M2.1 in central (https://repo.maven.apache.org/maven2)

I tried "running the Maven import with -U", which was what the compiler said would fix the error, but it still raised the same error. I also went to the repo.maven.apache.org website, and it didn't have nd4j there.

答案1

得分: 1

我认为您可能在错误的方式下包含了nd4j的依赖项。根据说明,您应该添加Deeplearning4j的依赖项:

<dependencies>
    <dependency>
        <groupId>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j-core</artifactId>
        <version>1.0.0-M2.1</version>
    </dependency>
</dependencies>

以及nd4j后端模块的依赖项,例如:

<dependencies>
    <dependency>
        <groupId>org.nd4j</groupId>
        <artifactId>nd4j-native-platform</artifactId>
        <version>1.0.0-M2.1</version>
    </dependency>
</dependencies>

您似乎使用了类似以下的内容:

<dependencies>
    <dependency>
        <groupId>org.nd4j</groupId>
        <artifactId>nd4j</artifactId>
        <version>1.0.0-M2.1</version>
    </dependency>
</dependencies>

这不起作用,因为该依赖项表示一个父POM而不是一个JAR文件。

我还访问了repo.maven.apache.org网站,那里没有nd4j。

我查看时那里有。但正如我所说,它是一个POM文件,而不是一个JAR文件。

英文:

I think you are trying to include nd4j dependencies the wrong way. If I am reading the instructions correctly, you are supposed to add the Deeplearning4j dependency:

&lt;dependencies&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.deeplearning4j&lt;/groupId&gt;
      &lt;artifactId&gt;deeplearning4j-core&lt;/artifactId&gt;
      &lt;version&gt;1.0.0-M2.1&lt;/version&gt;
  &lt;/dependency&gt;
&lt;/dependencies&gt;

and a dependency for one of the nd4j backend modules; e.g.

&lt;dependencies&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.nd4j&lt;/groupId&gt;
      &lt;artifactId&gt;nd4j-native-platform&lt;/artifactId&gt;
      &lt;version&gt;1.0.0-M2.1&lt;/version&gt;
  &lt;/dependency&gt;
&lt;/dependencies&gt;

You have apparently used something like this instead:

&lt;dependencies&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.nd4j&lt;/groupId&gt;
      &lt;artifactId&gt;nd4j&lt;/artifactId&gt;
      &lt;version&gt;1.0.0-M2.1&lt;/version&gt;
  &lt;/dependency&gt;
&lt;/dependencies&gt;

That doesn't work because that dependency denotes a parent POM not a JAR file.


> I also went to the repo.maven.apache.org website, and it didn't have nd4j there.

It was there when I looked. But as I said, it is a POM file not a JAR file.

huangapple
  • 本文由 发表于 2023年5月21日 12:19:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76298281.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定