IntelliJ cannot find any declarations

2019-03-08 00:24发布

I completely uninstalled IntelliJ and have now reinstalled and imported my project. I imported using gradle and can see all of the files in my project present. However, when I open a file I can't find any declaration to go to by doing cmd + click. I have the Java 7 SDK setup, and I can't even go to the declaration of classes in my own project. Going to a Java core class like String or List doesn't work either. How can I enable the IDE to be able to find my classes?

I'm on OSX Yosemite, IntelliJ 2016.1.2 build 145.972.

15条回答
混吃等死
2楼-- · 2019-03-08 00:29

Your source folders where your Symbols are (Classes) are need to be configured as "Content Root".

  • Open Project Structure: #;
  • Click Modules
  • You can configure your Content Root (Sources, Tests, Resources etc) for each module that you want to Navigate to.

Once done you should be able to navigate to your symbols.

查看更多
淡お忘
3楼-- · 2019-03-08 00:29

In my case, I just updated my IntelliJ to Ultimate 2018.2 and all of my projects suddenly cannot find the implementations and the 'src' folders - it turned out IntelliJ removed the type of project (e.g. Maven).

What I did is:

Right click on the root project > Add Framework support... > Look for Maven (in my case) > Wait to re-index again > Then it worked again.

查看更多
可以哭但决不认输i
4楼-- · 2019-03-08 00:34

I had this same problem, and @AniaG's solution in the comments worked for me.

  • Right-click src folder
  • Mark Directory as > Sources Root

enter image description here

查看更多
相关推荐>>
5楼-- · 2019-03-08 00:37

Came across the same issue and in my case (Java project), I had to include all the dependent jars in the project's libraries section.

File -> Project Structure -> Libraries

I had to add my project dependent jars in the above section (for example; project/web/lib/). After doing so, all resolved fine. I hope this will help someone.

查看更多
相关推荐>>
6楼-- · 2019-03-08 00:39

In my case I was using a gradle project with subprojects. The reason IntelliJ couldn't find declarations was that the subprojects were not built.

After investigating why subprojects were not built, I found out that using "auto-import" was breaking the subprojects.

After importing the project from build.gradle without auto-import, it worked for me.

查看更多
Rolldiameter
7楼-- · 2019-03-08 00:40

In my case, none of the above helped. Only upgrade of Intellij from 2017.3 to 2018.2 helped.

Do not try 2018.1 as it had a bug wherein the Find files popup would not come up.

查看更多
登录 后发表回答