[英]Eclipse (Photon) couldn't find my maven dependency jar
I am trying to import a library from my maven repo. 我正在尝试从我的Maven存储库导入一个库。 But I got the error saying "The import org cannot be resolved"
, screenshot below: 但是我收到错误消息"The import org cannot be resolved"
,以下屏幕截图:
However, we can see the jar under the Maven Dependencies from the Package explorer: 但是,我们可以在Package Explorer中的Maven Dependencies下看到jar:
Also, my pom.xml
looks like: 另外,我的pom.xml
看起来像:
<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>
<groupId>Test1</groupId>
<artifactId>Test1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<release>10</release>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>gregorian-calendar</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8</version>
</dependency>
</dependencies>
</project>
What did I miss here? 我在这里想念什么? What else do I need to import org.apache.commons.lang3.time.DateUtils
? 我还需要import org.apache.commons.lang3.time.DateUtils
吗? Thanks! 谢谢!
Note: I am on Mac 注意:我在Mac上
It looks like you have a module-info.java
. 看来您有一个module-info.java
。 In this case, you need to add requires org.apache.commons.lang3;
在这种情况下,您需要添加requires org.apache.commons.lang3;
to it (this is the automatic module name from the MANIFEST.MF
inside commons-lang3-3.8.jar
). 到它(这是commons-lang3-3.8.jar
MANIFEST.MF
的自动模块名称)。
Also, having MainTest1 in the default package is not allowed in a named module, so you have to move it into a package. 另外,命名模块中不允许MainTest1位于默认程序包中,因此您必须将其移动到程序包中。
Alternatively, you can remove the module-info.java
and things should mostly work like before Java 9 另外,您可以删除module-info.java
并且大多数情况下应该像Java 9之前那样工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.