我的 Eclipse 工作区中有 4 个项目。它们都是4个maven项目。名称为 API
、Games
、Faction
、Board
。
API
用于所有其他 Maven 项目(Games
、Faction
、Board
),其本身取决于将 jar 放入我的 PC 和 HikariCP 中。
我在 API pom.xml 中声明了此依赖项
<dependency>
<groupId>org.github.paperspigot</groupId>
<artifactId>paperspigot-api</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}\lib\paperspigot-1.7.10-R0.1-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.8</version>
<scope>compile</scope>
</dependency>
然后我在我的其他 3 个项目上声明它们依赖于 API
<dependency>
<groupId>net.onima</groupId>
<artifactId>onimaapi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
但是我对 API 有一个很大的警告,错误日志是这样写的:
我不明白为什么会出现这个错误,因为我可以在我的类中使用 API 进行编码。有人能给我解释一下吗?谢谢
编辑:根据要求,屏幕截图的文本:
描述 资源路径 位置类型
项目“OnimaAPI”缺少所需的 Java 项目:“paperspigot”OnimaAPI 构建路径构建路径问题
描述资源路径位置类型 项目“OnimaGames”缺少所需的 Java 项目:“onimaapi”OnimaGames 构建路径构建路径问题
我不知道为什么我不能在这里设置pom.xml
,所以这里有一个链接:https://ghostbin.com/paste/r4u62
最佳答案
您正在使用 system
范围声明 paperspigot
。
<dependency>
<groupId>org.github.paperspigot</groupId>
<artifactId>paperspigot-api</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}\lib\paperspigot-1.7.10-R0.1-SNAPSHOT.jar</systemPath>
</dependency>
Dependencies with the scope system are always available and are not looked up in repository. They are usually used to tell Maven about dependencies which are provided by the JDK or the VM.
您应该使用compile
范围来声明它:
This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
关于java - Maven 依赖奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54190712/