我正在尝试使用烧烤条形码打印库。我通过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中编码,还有其他地方需要添加库吗?
当前回答
这是一个经常发生的非常烦人的问题。尤其是在切换到不同的git分支之后。它浪费了我太多的时间来排除这种问题。以上方法我都试过了。但我找不到可靠的方法。在这里,我总结了那些可能对我的情况有所帮助的步骤。Jetbrains,请修复此问题以节省客户的宝贵时间。
确保执行成功的命令行构建(如果UT失败,请使用-Dmaven.test.skip=true忽略UT)。 在“Maven Projects”视图中,尝试使用“重新导入”所有的Maven项目。 在文件菜单中,使用“无效缓存” 删除。idea文件夹,基本上从头开始创建工作区。(这是唯一可靠的解决方法)
其他回答
我也遇到了同样的问题,通过将设置中的“Maven主目录”从“捆绑”更改为本地安装的Maven,我解决了这个问题。也许这触发了某种刷新的地方,因为我没有改变这个设置几个月没有任何问题。
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.
我试着
“Maven >重新导入” 删除.idea目录,并重新打开项目。 文件->使缓存无效/重新启动然后构建->重建项目 删除本地.m2文件夹内的内容,并重新下载依赖项。 在Maven控制台中运行mvn idea:idea(虽然这个命令已经过时了,但我不得不尝试。)
在不同的组合中。
但是从Intellij 2020版本到2019版本解决了我的问题。
我在更改pom后得到了这个错误,我通过execute修复了它:
mvn idea:module
这对我很有用
无效缓存/重新启动,然后构建->重建项目帮助我