Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change java project source in VSCode?

After creating the basic hello world Spring Java application I am getting this lint error for the 'hello' package definition:

The declared package "hello" does not match the expected package "main.java.hello"

I understand in Eclipse you can change the Java source directory to be /src/main/java instead of just /src. How can I achieve the same in VSCode?

like image 575
steve Avatar asked May 29 '26 02:05

steve


2 Answers

You can right-click on src/main/java in Explorer and choose "Add Folder to Java Source Path", and restart VSCode.

like image 196
Максим Наумов Avatar answered Jun 02 '26 03:06

Максим Наумов


In the .vscode/settings file set

"java.project.sourcePaths": [
     "src/main/java"
 ]

or edit the Workspace settings and find the java.sourcePaths property.

like image 44
patthoyts Avatar answered Jun 02 '26 03:06

patthoyts



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!