4

解决 Intellij IDEA 不识别某些 class 的问题

 2 years ago
source link: https://www.felix021.com/blog/read.php?2238=
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

解决 Intellij IDEA 不识别某些 class 的问题

解决 Intellij IDEA 不识别某些 class 的问题 不指定

又遇到一个灵异的 intellij idea 问题。

背景:在项目 P 的同一个 Module M 下面, PKG P1 需要 import PKG P2 下面的 C1 和 C2 两个 class。

现象:import C1 成功,但是import C2失败;然而通过 mvn clean install 是可以正常完成编译的。

删除 project 下的 .idea 目录重新 import 并没有解决这个问题。

在另一个同学的电脑上尝试,报的错竟然不一样,是在 C2 这个 class 下无法 import 另一个 class C3,但同样可以通过 mvn 命令行完成编译。

通过 Google 搜到 StackOverflow 的这个 thread:

https://stackoverflow.com/a/66167190/802910

解决方案很简单:删掉 idea 的cache 目录,让它重建就好了。

在 windows 下,这个目录位于 %LOCALAPPDATA%\JetBrains\IdeaIC2021.2\caches (注意替换为自己版本号)

在 mac 下,目录应该是 ~/Library/Caches/JetBrains/IdeaIC2021.2

似乎 IDEA 本身也有清空 cache 的功能(File -> Invalidate Caches...),下次遇到再验证一下。


欢迎扫码关注:

weixin1.png

转载请注明出自 https://www.felix021.com/blog/read.php?2238 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK