Java IntelliJ中的包不存在错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20137020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Package doesn't exist error in intelliJ
提问by Tika
I'm trying to use the barbecue barcode printing library. I have successfully added the library to IntelliJ through project structure add library. Then I imported the packages and wrote the methods, which gave me no error. The packages were available in the class.
我正在尝试使用烧烤条码打印库。我已经通过项目结构添加库成功地将库添加到 IntelliJ。然后我导入了包并编写了方法,这没有给我带来任何错误。这些包在课堂上是可用的。
But when I compile it gives me the error:
但是当我编译它给了我错误:
error: package net.sourceforge.barbecue does not exist
How can this be?
怎么会这样?
I'm coding in ubuntu, is there any other place to which I have to add the library?
我在 ubuntu 中编码,还有其他地方需要添加库吗?
Thanks. Tika
谢谢。蒂卡
回答by vikingsteve
If you added a library to the project structure (rather than via maven, that would be different), be sure it is included as a dependency for the relevant module.
如果您向项目结构中添加了一个库(而不是通过 maven,那会有所不同),请确保将其作为相关模块的依赖项包含在内。
Project Structure -> Modules -> Dependencies
项目结构 -> 模块 -> 依赖
回答by Saleh Hamadeh
I had the same problem. I fixed it by applying the android-apt plugin https://bitbucket.org/hvisser/android-apt
我有同样的问题。我通过应用 android-apt 插件https://bitbucket.org/hvisser/android-apt修复了它
回答by humanity
Right click your project / Maven (at bottom) / Reimport
右键单击您的项目/Maven(底部)/重新导入
Edit, much later: I also saw this happen much more frequently when I had the Clover plugin installed. Drop that plugin like a bad habit!
编辑,很久以后:当我安装了 Clover 插件时,我也看到这种情况更频繁地发生。像坏习惯一样放弃那个插件!
回答by mattalxndr
I tried to "Maven > Reimport" but the only thing that actually fixed it was to close the project, delete the .idea directory, and reopen the project.
我尝试“Maven > Reimport”,但唯一真正修复它的是关闭项目,删除 .idea 目录,然后重新打开项目。
回答by Durgesh Suthar
Just reimport didn't work. Following worked for me.
只是重新导入没有用。以下为我工作。
File -> Invalidate Caches /Restart
文件 -> 使缓存无效/重新启动
Then
然后
Build -> Rebuild Project
构建 -> 重建项目
That will reimport maven project.
这将重新导入 maven 项目。
回答by Pratik Nagelia
Tried all the above approaches, didn't work.
Finally running maven clean install
solved it!
上面的方法都试过了,还是不行。终于运行maven clean install
解决了!
回答by Graeme Moss
I had the same problem and it was fixed for me by changing the "Maven home directory" in Settings from "Bundled" to my locally installed maven. Perhaps this triggered some kind of refresh somewhere since I had not changed this setting for months without any issue.
我遇到了同样的问题,通过将“设置”中的“Maven 主目录”从“捆绑”更改为我本地安装的 Maven 来修复它。也许这在某处触发了某种刷新,因为我几个月没有更改此设置而没有任何问题。
回答by Antoine
Quit IntelliJ, remove every .idea
directory:
退出 IntelliJ,删除每个.idea
目录:
rm -Rf **/.idea/
and restart.
并重新启动。
回答by Andrey
menu -> build -> Rebuild Project
has worked for me
对我有用
(Invalidating caches without this step doesn't help)
(没有此步骤使缓存无效无济于事)
回答by Srikanth Reddy
Invalidate Caches/ Restartand then Build -> Rebuild Projecthelped for me
Invalidate Caches/ Restartand then Build -> Rebuild Project对我有帮助