Because vscode set the src folder as the default Java Source Path, you should change it to folder src/main/java. Just right click the folder src/main/java in vscode and click the option Add Folder to Java Source Path, then reopen the file, and the error is gone.