pranay
pranay

Reputation: 2369

package not found error in building pom in maven

i am trying to compile a pom file for a project (say com.mycompany.package2). Now some of the files have import statements like import com.mycompany.package1.someClass .So i made a pom file for files in com.mycompany.package1 and added this pom as a parent to pom made for com.mycompany.package2 . However, on executing mvn compile for this new pom (com.mycompany.package2) i get error that the package com.mycompany.package1 does not exist. I can't understand why am i getting this error and how to correct it? Thanks.

Upvotes: 2

Views: 8702

Answers (2)

chirag25
chirag25

Reputation: 65

For me it worked like this way, I added all my packages under src/test and after that this issue was resolved

Upvotes: 0

austin
austin

Reputation: 1171

i would advice you to go your .m2 folder which is your local maven repository folder (or where-ever you have your maven repository) to check if you can find package1.jar/war
if you dont find it, then you can be sure - you have not compiled your package1 in the first place, in which case you should do a maven compile(mvn install) to your project1 first before you do it to your project2
EDIT if project2 has import of project1, then project1 is a dependency to project2
in which case you need to add project1.jar as a dependency in your project2 pom file... like this

<dependency> <groupId>package1</groupId> <artifactId>com.mycompany.package1</artifactId> <version>1.0.0</version> </dependency>

Upvotes: 2

Related Questions