Why so red? IntelliJ seems to think every declarat

2019-01-20 23:33发布

I just installed and re-installed IntelliJ. Every Java file is coming up RED. I checked the JDK; it is at 1.6.##. The maven clean install build worked just fine.

I'm getting the usual highlighted errors. On every declaration:

Cannot resolve symbol SomeEntityBean/Bean

and on every method:

Cannot resolve method SomeFunction()

How do I fix these false errors?

21条回答
走好不送
2楼-- · 2019-01-21 00:13

These 3 steps almost always work for me :

Step 1 - File -> Invalidate cache/ Restart

Step 2- If you see that in File -> Project Structure -> SDKs the SDK is red, Try to configure it properly as explained here

Step 3 - Update Java versions in

a) File -> Project Structure -> Project
b) File -> Project Structure -> Module (Sources and Dependencies tab)
c) Preferences -> Java Compiler
查看更多
3楼-- · 2019-01-21 00:14

I was trying to use all the advices above, but unfortunately no one helped me. So finally I've decided to delete my intelij workspace and create the new one - it helped :) But earlier I was also doing cleaning the cache, reimporting maven projects, cleaning projects and rebuilding them.

查看更多
Root(大扎)
4楼-- · 2019-01-21 00:14

I had the same issue I was using JDK 1.9 with IntelliJ 14, I solved reinstalling Java with latest version of JDK 1.8(1.8.0_161 in this case)

I also removed the 1.9 version from

HKEY_CURRENT_USER\Software\JavaSoft\JRE\Security Baseline

查看更多
Emotional °昔
5楼-- · 2019-01-21 00:17

IntelliJ sometimes gets confused all by itself, even without the external changes Korgen described (though that is a good way to consistently reproduce it).

Click File -> Synchronize, and IntelliJ should see that everything is okay again.

If that doesn't work, IntelliJ's caches might be corrupt (this used to happen a lot more often than it does now); in that case, regenerate them by

Clicking File -> Invalidate Caches and restarting the IDE

(though loading the project will take a while while the caches are recreated).

查看更多
放荡不羁爱自由
6楼-- · 2019-01-21 00:18

I had the same problem after changing JDK from 1.6 to 1.7 in my pom.xml and setting Maven 3 path + JDK project settings to 1.7.

What did it for me was => File -> Invalidate Caches and Restart

PS: problem occured again, so i just reimported the full project after deleting the .idea folder and now it works fine as usual :)

查看更多
闹够了就滚
7楼-- · 2019-01-21 00:20

I had the same problem.

In my case the problem was with maven home directory and user settings file in Intellij Settings under Maven. I had installed Maven not in the default directory and I had also changed the location of the settings.xml file. This should also be changed in the IntelliJ Settings.

Hope this helps also.

查看更多
登录 后发表回答