我正在尝试使用烧烤条形码打印库。我通过project structure add library成功将库添加到IntelliJ。然后我导入了包并编写了方法,这没有给我任何错误。这些包在类中可用。
但是当我编译时,它会给我一个错误:
error: package net.sourceforge.barbecue does not exist
这怎么可能呢?
我在ubuntu中编码,还有其他地方需要添加库吗?
我正在尝试使用烧烤条形码打印库。我通过project structure add library成功将库添加到IntelliJ。然后我导入了包并编写了方法,这没有给我任何错误。这些包在类中可用。
但是当我编译时,它会给我一个错误:
error: package net.sourceforge.barbecue does not exist
这怎么可能呢?
我在ubuntu中编码,还有其他地方需要添加库吗?
当前回答
我在IntelliJ 2020.3中遇到了这个问题,并尝试了无效缓存选项并重新构建,但问题仍然存在。唯一修复它的方法是重命名包,并将其重命名为原来的样子。
其他回答
我尝试“Maven >重新导入”,但唯一真正修复它的是关闭项目,删除.idea目录,并重新打开项目。
右键单击项目/ Maven(在底部)/重新导入
编辑,很久以后:当我安装了Clover插件时,我也看到这种情况更频繁地发生。像扔掉坏习惯一样扔掉那个插件!
类似于cvdr。过高的Java版本可能是问题所在。
在我们的测试项目中,一个大学生在使用多个java源代码时遇到了这个问题。她刚刚更新到一个更高的Intellij,当我们调查的时候,没有一个重建选项有效,但Intellij似乎已经“碰撞”了项目Java设置到Java 11(我猜它在升级安装时需要最高的安装版本?)将其设置回Java8,项目编译成功。
点击文件>项目结构>项目设置>项目,在下拉菜单中选择正确的。
我在更改pom后得到了这个错误,我通过execute修复了它:
mvn idea:module
这对我很有用
I created two new classes under a new package and used it in rest of the code, Intellij was able to resolve these no red highlights were shown in the intellij editor. While building it was showing package doesn't exist error. I tried everything from gradle clean build, rebuild project, clear .idea and .gradle and reimporting the project, clearing the gradle local cache but nothing was working. Finally I refactored the name of the new package and this time intellij was able to recognize the new classes and it started working.