我正在尝试使用烧烤条形码打印库。我通过project structure add library成功将库添加到IntelliJ。然后我导入了包并编写了方法,这没有给我任何错误。这些包在类中可用。

但是当我编译时,它会给我一个错误:

error: package net.sourceforge.barbecue does not exist

这怎么可能呢?

我在ubuntu中编码,还有其他地方需要添加库吗?


当前回答

遵循以下步骤:

Ctrl+Shift -> Type Invalidate Caches ->检查所有选项,除了:Ask before… 高级菜单->构建->重建项目

其他回答

只是重新导入不起作用。下面的方法对我很有效。

File ->使缓存失效/重新启动

Then

Build ->重建项目

这将重新导入maven项目。

注意:您需要使缓存无效并重新构建项目。

如果你不想破坏。idea,你可以尝试:

开放项目结构>模块 将Java文件夹取消标记为源文件夹 应用/重建 然后再次将其标记为源文件夹 重建

我在IntelliJ 2020.3中遇到了这个问题,并尝试了无效缓存选项并重新构建,但问题仍然存在。唯一修复它的方法是重命名包,并将其重命名为原来的样子。

我在更改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.