從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以后項目就好使了哈哈