Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Directory structure after converting a project to maven in eclipse

I have a java project, which i converted to maven using m2e from within eclipse. Since my project was a legacy project, it was not following maven directory structure such as src/main/java and src/test/java, so after the conversion the previous directory structure didnt change.

I am wondering if there is an easy way or shortcut within m2eclipse to refactor my project to the default directory structure used by maven.

I tried adding a new source folder in my src folder and nest the folders to have src/main/java but I am getting the below error.

Please see the snapshot as i dont have enough reputation to post it.

Snapshot

like image 501
Saad Avatar asked Dec 05 '25 10:12

Saad


1 Answers

The error message is pointing out the problem - you can't nest source folders, as the package names would make no sense. It is easily fixed:

  • Right click the project and select Properties
  • Select Java Build Path/Source
  • Delete all entries
  • Add the standard Maven paths (src/main/java, src/main/resources, /src/test/java and src/test/resources)

Exit the Properties dialog and a Project/clean should compile everything correctly.

like image 116
kiwiron Avatar answered Dec 07 '25 23:12

kiwiron



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!