Skip to content
Advertisement

VSCode Maven “X.java is not on the classpath of project Y”

Currently I have an issue with Maven is Visual Studio Code where it reports errors related to the classpath.

The project structure is as following:

JavaScript

And the pom.xml of project has:

JavaScript

This POM only serves as ‘dummy’ in order to compile each sub project

And in the pom.xml of each subproject has the following:

JavaScript

When going to any Java source file in a sub project I get the following error: SOURCENAME.java is not on the classpath of project PROJECTNAME, only syntax errors are reportedJava(32)

How can I add the src directory of each sub project to the classpath so it will report compile errors? When I tell VSCode to report compilation errors anyway everything is highlighted in red because it can’t find the dependencies.

When I run mvn compile package it compiles the sub projects successfully. Only VSCode is complaining.

Advertisement

Answer

In each sub project the parent needs to be defined as well.

JavaScript

And now VSCode works as expected.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement