我正在尝试使用烧烤条形码打印库。我通过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中编码,还有其他地方需要添加库吗?
当前回答
这里有一个对我有效的解决方案: 禁用交叉编译的“Use -release”选项,如下所示: 得到设置->构建,执行,部署->编译器-> Java编译器和禁用:
使用'——release'选项进行交叉编译(java 9及更高版本)
其他回答
只是重新导入不起作用。下面的方法对我很有效。
File ->使缓存失效/重新启动
Then
Build ->重建项目
这将重新导入maven项目。
注意:您需要使缓存无效并重新构建项目。
我也遇到了同样的问题,通过将设置中的“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从捆绑到我自己的Maven发行版。
我认为反之亦然(从自己的改变到捆绑)也会有所帮助。
Maven重新导入,重新构建和无效缓存不工作。我通过打开一个终端并在根文件夹项目中执行maven clean install解决了这个问题。(IntelliJ被打开,我能够看到IDE更新和触发驯鹿,而maven正在做他的工作)