从git上拉取下来项目以后,每个class文件图标都是灰色的,进去里面ctrl+鼠标左键跳转不了别的类,而且系统中有这些类,却一直提示 Cannot find declaration to go to。
百度了很多方法,什么关掉当前项目然后重新import啊,什么项目右键Mark directory as --> Sources root之类的通通不管用。
直到看到了这个方法,在此记录一下,日后慢慢研究。
原文链接:https://www.cnblogs.com/ShaYeBlog/p/11250035.html
附上解决方法:
- close the project in intellij. 关闭当前idea中的项目
- close intellij. 关闭idea
- go to the project folder and delete the
.idea
folder 前往项目的文件夹中删除.idea文件夹 - restart intellij and open the project (wait for the indexing to finish) and it would work. 重新启动idea并且打开修改后的项目等index更新完成就可以了
其实本人我的操作是直接去文件夹里把.idea文件删了,然后再file -> InvalidateCaches/restart -> InvalidateCaches/restart重启完idea以后项目就好使了哈哈