Maven, package does not exist
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).
While working with IntellijIDEA, generated files can cause this issue. Writing
mvn idea:idea
on IntellijIDEA Maven console to reset those files did the trick for me. Also, see: Package doesn't exist error in intelliJ
For anyone struggling with this and not familiar with java, make sure that the said package exists in your local repository. Maven has a local repository ~/.m2
where the packages are installed for local access, so even if your dependency package is correctly declared as a dependency in pom.xml
and is compiled and exists in your project, if it does not exist in the local repository, the mvn compile
will trigger a "package does not exist"
error.
To fix this:
In the missing package folder, do:
mvn install //--> this will package and install your missing package in the local repo
Then in your project that you wanted to compile:
mvn compile // --> now that the missing package is in the local repo it should work