我正在尝试使用烧烤条形码打印库。我通过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中编码,还有其他地方需要添加库吗?
当前回答
我尝试了所有的答案,但最终帮助我的是将Maven从捆绑到我自己的Maven发行版。
我认为反之亦然(从自己的改变到捆绑)也会有所帮助。
其他回答
以上方法都试过了,都没用。 最后运行maven清洁安装就解决了!
我尝试用JDK 12编译一个java 8项目,也有同样的问题。 以前的答案没有一个能解决我的问题。
我把Shortel命令行改为“JAR Manifest”,工作起来很有魅力。
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.
如果你不想破坏。idea,你可以尝试:
开放项目结构>模块 将Java文件夹取消标记为源文件夹 应用/重建 然后再次将其标记为源文件夹 重建
如果你尝试了建议的方法,仍然没有机会,请确定你的订单:
删除你的。idea/ 无效和重新启动缓存之后 从maven工具导入maven项目
如果你没有在删除你的.idea/后无效并重新启动缓存,Intellij会继续生成它,这在我的情况下是错误的。