声明的包“"与预期的包不匹配 [英] The declared package "" does not match the expected package
问题描述
我能够编译和运行我的代码,但 VSCode 中总是显示错误.早些时候有一个弹出窗口,我不记得是什么,我点击了全局应用",从那以后就一直这样了.
I'm able to compile and run my code but there is always an error showing in VSCode. Earlier there was a pop up I don't remember what and I clicked "apply globally" and it's been this way since.
输出在那里,但错误也在那里
Output is there but so is the error
声明的包"与预期的包不匹配
The declared package "" does not match the expected package
推荐答案
感谢上面@beatrice 的评论,我找到了答案 此处.
Thanks to the comment of @beatrice above, I found the answer here.
我的 .vscode\settings.json
文件明确添加了一些路径.当 Visual Studio 代码没有异常时,我通过右键单击某些项目文件夹并执行将文件夹添加到 Java 源路径"手动添加了它们.
My .vscode\settings.json
file had some paths explicitly added. I had added them manually when Visual Studio code was not misbehaving, by right-clicking on certain project folders and doing "add Folder to Java source path".
对我来说,解决方案基本上是从 .vscode\settings.json
中删除所有这些内容,将其内容替换为:
The solution for me was to basically remove all of them from .vscode\settings.json
, replacing its contents with:
{
"java.project.sourcePaths": [""]
}
这终于让 VsCode 再次工作了.
This finally made VsCode work again.
这篇关于声明的包“"与预期的包不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!