vs code 提示[myfile].java is a non-project file, only syntax errors are reported

今天在用vs code直接打开一个Java 文件的时候,vs code提示 [myfile].java is a non-project file, only syntax errors are reported 。如下图一所示。搜索了一下发现大部分都是关于Warning: Classpath is incomplete. Only syntax errors will be reported.跟这个Warning相关的很难找到,不过还在根据一个StackOverflow上的问答找到了问题所在,就是vs code在打开一个文件的时候,直接通过点击File->Open File打开之后(如图二),在编辑器左侧还会让你再打开该文件所在的文件夹,然后Warning就消失了。而且StackOverflow上说最好是打开直接父文件夹,而不是间接的父文件夹,不过我尝试了一下并没有使问题重现。

另外就是我感觉在vs code打开文件的正确姿势应该是先Open Folder,然后Open File,而不是直接Open File,还有就是Open Folder的时候是不会显示Folder里面的内容的,这个是正常的,打开Folder之后才会显示,我刚开始以为是出错了呢。

如果对你有帮助希望点赞支持一下!
图一
vs code 提示[myfile].java is a non-project file, only syntax errors are reported_第1张图片
图二
vs code 提示[myfile].java is a non-project file, only syntax errors are reported_第2张图片

你可能感兴趣的:(编程途中的那些bug)