Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven, package does not exist

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>

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>

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

No luck. I tried in both the IDE (IntelliJ) and in commandline. Any idea? thanks

like image 933
EyeQ Tech Avatar asked Mar 05 '13 00:03

EyeQ Tech


People also ask

What is Mvn clean install?

mvn clean install is the command to do just that. You are calling the mvn executable, which means you need Maven installed on your machine. (see How do you install Maven?) You are using the clean command, which will delete all previously compiled Java . class files and resources (like .

How do I install pom dependencies?

Right, click on the project. Go to Maven -> Update Project. The dependencies will automatically be installed.


1 Answers

From your sample, we cannot see any artifact containing the package com.mycompany.common.objects you are using.

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).

like image 198
Adrian Shum Avatar answered Sep 17 '22 15:09

Adrian Shum