Maven,包不存在 [英] Maven, package does not exist
问题描述
我有一个模块,其pom文件为:
I have a module whose pom file is:
<groupId>com.mycompany.Common</groupId>
<artifactId>common</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>common module</name>
在该工件(普通")中,我有一个名为com.mycompany.common.objects的软件包.在使用程序包中,我的pom文件是:
In that artifact ('common'), I have a package named com.mycompany.common.objects. In the consuming package, my pom file is:
<dependency>
<groupId>com.mycompany.Common</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
</dependency>
当我运行mvn install时,总是会抱怨:包com.mycompany.common.objects不存在.
When I run mvn install it always complain: package com.mycompany.common.objects does not exist.
我尝试在错误所在的类中明确导入:
I tried explicit importing in the class where the error was:
import com.mycompany.common.objects
没有运气.我在IDE(IntelliJ)和命令行中都尝试过.任何的想法?谢谢
No luck. I tried in both the IDE (IntelliJ) and in commandline. Any idea? thanks
推荐答案
从您的示例中,我们看不到任何包含您正在使用的软件包com.mycompany.common.objects
的工件.
From your sample, we cannot see any artifact containing the package com.mycompany.common.objects
you are using.
您正在将com.mycompany.Common:common依赖项添加为POM(并且还将com.mycompany.Common:common的包装也声明为POM).如果它实际上是一个JAR工件,其中包含您需要使用的软件包,则从POM和依赖项中删除packaging
(这意味着,使用默认值JAR).
You are adding dependency com.mycompany.Common:common as a POM (and you are declaring the packaging of com.mycompany.Common:common as POM too). If it is actually a JAR artifact that contains the package you need to use, then remove the packaging
from the POM and dependency (which means, using default which is JAR).
这篇关于Maven,包不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!