Compile Error in IDEA but Not Maven

Answered

If I clean and compile with maven I get no compile errors.
However, if I do Build->Rebuild Project or Build->Make project I get compile errors such as
"cannot find symbol variable "

Clearly IDEA is out of sync with something
Is there any way to force the cache to refresh to fix this?

0
13 comments

Hi,
Could you please attach a sample project that demonstrates the problem?

Thanks,
Anton Makeev

0

Unfortunately I can't attach the specific project for confidentiality reasons.
If I can duplicate it with another project I will attach that.
Meanwhile, clicking re-import maven projects seemed to fix it.

0
Avatar
Permanently deleted user

I think I might have the same problem ...

Until today I have been using the command line to execute maven commands.  Whenever a pom changed, I would execute 'mvn idea:idea' to regenerate the project files and update dependancies.  This worked fine in 8.0.

Yesterday, under 8.1, I changed two dependencies: spring from 2.5.5 to 2.5.6 and wicket from 1.4-rc1 to 1.4-rc2.  Everything works as expected on the command line and everything seemed fine in the IDE, however, this morning the IDE is not recognising the new jars.  I have now set up the IDE to use the maven plugin - I had the plugin auto generate the config from the poms it found under the project.  Now I see ...

If I have the wicket dependancy set to rc2, I see compile errors in my code window.
Change the pom to rc1 and re-import - all the compile errors go away and I can see the contents of the jars in the project heirarchy/libraries pane.
Switch back to rc2 and re-import, the errors return and I cannot see the contents of the jar in project heirarchy/libraries.

The same thing happens with the spring jars.

The jars are definitely in my local repository, as I say, running maven at the command line with the upgraded poms works fine, in fact running 'clean:install' from the plugin uses the updated jars too; it's just the IDE that seems to ignore the jars.

0

Hi, Alan,

We do not support maven-idea-plugin.
If you have the same problem with the built-in Maven Integration, please let me know and attach a sample project, if it is possible.

Thanks,
Anton Makeev

0
Avatar
Permanently deleted user

Sorry, it is the Maven Integration that I'm using.

0
Avatar
Permanently deleted user

Ok, I created a dummy project (no need to attach it because the instructions to create it are below) to help you solve the problem ... except the problem has gone away !!!  Actually, as you'll see from the following list there are still issues, but I'm not sure how important they are:

Create a new wicket project: mvn archetype:create -DarchetypeGroupId=org.apache.wicket -DarchetypeArtifactId=wicket-archetype-quickstart -DarchetypeVersion=1.4-rc1 -DgroupId=com.mycompany -DartifactId=myproject

cd myproject
mvn idea:idea

double click on myproject.ipr
convert to new format


change pom: wicket.version, rc1 to rc2

mvn idea:idea
intellij prompts to reload project .. click yes
rc2 jar not available, errors in HomePage.java  BUT mvn clean install at command line, war file created, correct jar in WEB-INF/lib!


Change pom: jetty.version, 6.1.4 to 6.1.10
intellij prompts to reload project .. click yes
It works as expected!!!


'delete' my .m2/repository directory
mvn clean install (pom set to wicket rc1)
mvn idea:idea


change pom: wicket.version, rc1 to rc2
mvn clean install
rc2 jar added to repository
mvn idea:idea
rc2 not available to IDE


Click on 'maven projects' tab.
Let plugin find pom files ...
modify pom, prompted to 're-import', click yes ...
creates duplicate entries for jar files ... manually remove those not prefixed by 'maven:'
Fine with wicket set to rc1
change to rc2
It works!!!


Restart intellij
Everything is ok!!!


Finally, I removed all of the intellij project config files from my main project and recreated the project using 'import from external model' - this seems to have solved my problem and a couple of other minor irritations (e.g. not able to recognise web module type after mvn idea:idea).  I repeated this process with the quickstart wicket project and everything worked first time!


I'm not sure what effect cleaning my repository had on the above, however, I suggest the solution is to not use mvn idea:idea at the command line, but rather to use 'import from external model' and to have the Maven Integration manage dependencies.

0

OK, then.
Please attach a sample pom project (just a little project with a dependency that cause the problem) and exact steps to reproduce the problem.

Thanks,
Anton Makeev

0

Now I don't undestand you at all: you've said that you use Maven Integration, but in the steps you mention mvn idea:idea.
By Maven Integration I mean our bundled IDEA plugin. You may open a Maven project with either Open Project action or New Project->Import from external model wizard.

0
Avatar
Permanently deleted user

Until today I was using the command line to execute maven commands.  I did so because 'mvn idea:idea' is what I used on previous projects and up until yesterday this worked fine on this project.

Today, while trying to fix my problems I switched to using Maven Integration.  In the steps above, I start with command line and manage to recreate my problems with the quickstart wicket project.  I then switched to using Maven Integration and 'create project from external model' - this solved my problems.  I will use this method in future projects.

0

Thanks, Alan,
Let me know if you have problems with Maven Integration in future.

Anton Makeev

0
Avatar
Permanently deleted user

for some reasons idea cannot run main class in my gradle spring boot project with some strange error:

Error:Maven Resources Compiler: Maven project configuration required for module 'pgr2dbc' isn't available. Compilation of Maven projects is supported only if external build is started from an IDE.

why? 

NOTE: ./gradlew build works fine

0

Do you use Maven for this project (Check the Maven tool window for any projects imported there)? Do you use 3rd plugins? Please check https://youtrack.jetbrains.com/issue/IDEA-210533#focus=streamItem-27-3397123.0-0 - try disabling 3rd plugins if you use any.

You could also try re-importing project via File | New | Project from Existing Sources and select build.gradle.kts to import from.

0
Avatar
Permanently deleted user

Thanks for your response, but It was Gradle project and I didn't used anything maven specific.

Seems like root cause was not enabled annotation processing in IDEA for my project while code actually contained lombok annotations in place

It's was really weird and confusing to see such a wrong error message, but I understand that it's hard to control from IDE perspective

 

0

Please sign in to leave a comment.