Intellij shows compilation error after switching branches

已回答

I have IntelliJ 2017.3 Ultimate version on OSX. As soon as I switch branches, more often than not I get compilation errors (maven build is just fine). This has been really frustrating.

1. I have tried Maven->ReImport (doesn't work)

2. Build Project (doesn't work)

3. I have done #1, followed by #2 (doesn't work)

4. Invalidate Cache and Restart (doesn't work)

Well #4 works 6 out of 10 times but its a slow work around and kills productivity. What works always is mvn clean idea:idea but again too slow and shouldn't be needed all the time and again kills productivity. What is it that I can do get this more consistent and better?

 

 

0

Do you generate Maven projects using idea task instead of importing from pom.xml?

0

Sorry I didn't follow completely. So initially I imported this project as a maven one, long time back in IntelliJ. I didn't generate using idea task. Is that what you are asking?

0

Yes, but you've mentioned using `mvn clean idea:idea`. This will overwrite IntelliJ IDEA generated project files and use the files generated by Maven instead.

Does the issue occur with the current 2017.3.3 version?

Does your Maven build generate any sources, uses annotation processors, etc?

In order to address this type of issue, it needs to be reproduced locally. If you have the steps, please report at https://youtrack.jetbrains.com/issues/IDEA.

0

This issue occurs in below version. My maven build generate sources I believe, I don't know about annotation processors. The project I'm working on can't be shared so I can't put it on public github for sharing. But I'll try to reproduce it on some other project.

What are your suggestions? What else I should be doing/not doing?

Thanks,

Nilesh

IntelliJ IDEA 2017.3 (Ultimate Edition)
Build #IU-173.3727.127, built on November 27, 2017
Licensed to XXXX
Subscription is active until February xx, xxxx
JRE: 1.8.0_152-release-1024-b6 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6

0

I'd start with updating to the current IDE version, yours is old.

You can also try https://www.jetbrains.com/idea/nextversion/.

0

Thanks, will update and post back in case of issues

0

Updated to below, still has the same compilation error issue. Maven build passes fine

 

IntelliJ IDEA 2018.1 EAP (Ultimate Edition)
Build #IU-181.3007.14, built on January 24, 2018
IntelliJ IDEA EAP User
Expiration date: February xx, xxxx
JRE: 1.8.0_152-release-1136-b5 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.12.6

0

Delete .idea directory and reimport from Maven. Don't commit project files that are generated from Maven into Version Control: https://intellij-support.jetbrains.com/hc/articles/206544839.

0

After struggling for literally 1 week, I finally found the solution. I tried so many permutations & combinations suggested in so many threads, but nothing actually worked for me.

Here's the thing:

IntelliJ is showing the errors because the dependencies are internally messed up. It doesn't mean they don't exist! They do, but mixed up. If there is an internal conflict with the wrong existing dependency, IntelliJ blindly skips it - which causes these huge errors for us.

Best course of action, according to me is: Delete all the contents inside .m2 repository & re-run maven clean install from terminal. Then re-load projects in IntelliJ

Note: Never delete whole .idea folder manually

0

请先登录再写评论。