IntelliJ recognizes module reference but Maven gives build error

Answered

(IDEA 2017.1.2) I have a project with multiple modules. I have added a class to an existing module (A), properly referenced the module AND CLASS in module (B), referenced module A in module B, and then rebuilt the entire project using Maven.  It  recognizes the reference ( I can see the class in the import using autocomplete and there is no error in the IDE).

But when I build with maven I get this:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project "MYPACKAGE": Compilation failure: Compilation failure:
[ERROR] "MYPATH".java:[8,42] package com.MYPACKAGE.MYCLASS does not exist

I have spent quite a bit of time on this and can find no answers. Any help is appreciated.

0
5 comments

Please share a sample project to reproduce the problem. Note that all the dependencies must be set in pom.xml files, everything you change manually in IntelliJ IDEA module settings will be discarded on the next Maven project reimport since Maven sync is one way only.

0

They are set in POM files. I installed the locally created jar in my local Maven repo then referenced it in my project's POM and I still get this:

[ERROR] location: variable criteria of type MyClass
[ERROR] /Users/home/MyProject/MyClass.java:[79,20] error: cannot find symbol
[ERROR] symbol: method setMySetter(boolean)

0

We still need a reproducible test case.

0

I'm experiencing the same issue. I'm sorry I can't send you my project. This is due some company policies. But I can provide you the steps to make the error happen:

1) create a new source directory in your project.

2) include some java files.

3) import those files.

4) change de files from step 2 to another source directory.

0

I made thinks work out for me.

Steps I did:

Delete the .idea folder

Import the projects

Config the source folders

Config a debug configuration

When I start de debug I could notice that IntelliJ recompile all the classes in my project. Maybe this did the trick.

After that Maven worked again pretty fine.

0

Please sign in to leave a comment.