I’m new to Gradle and I’ve generated a Gradle application project using the gradle init. It’s working fine when I run gradle run, however, VSCode shows the error
The declared package “console.menu” does not match the expected package “app.src.main.java.console.menu”
I know it has something to do with classpath, but I don’t know how to fix it. Is this a VSCode problem? Or there is something I can do with Gradle to get rid of this error as well? E.g., maybe there’s a configuration I can put in build.gradle to help VSCode realize the source structure of this project? By the way, this is an “application” project.
I’m not a VSCode user, but I’m guessing you need to import your project as a Gradle project so that VSCode knows what type of project it is. Currently it’s thinking your root directory is a java source directory. Once you tell VSCode this is a Gradle project, it should determine that “app/src/main/java” is a java source directory.