Search code examples
javavisual-studio-codegradlesyntax-highlighting

Vscode shows fake import errors when saving a file | Java


After saving/modifying the file, vscode highlighting an error importing my com.papersaccul into visual studio code Despite the fact that gradle.build specifies the path

sourceSets {
    main {
        java {
            srcDirs = ['src/main/java']
        }
    }
}

If I switch to another window and switch back, the errors disappear. The application works fine, built via gradle



after ctrl+s

after switch window



jetbrains doesn't have that problem.

I think the problem is in the standard java debugger (vscjava) even though I've kind of configured the build through gradle in .vs


Solution

  • Restart vscode after using the following command:

    Ctrl+Shift+P --> Java: Clean Java Language Server Workspace