I have created a project using the following maven webapp project in eclipse:
When adding a package to the project (right click project -> new -> package), the package gets added as a folder (I added a package named core). It does not have the usual package icon:
If I try to create a new class and select a package, there are no entries in the list box. I have tried creating packages in a normal eclipse dynamic web project and these work correctly.
How do I get packages in Maven enabled webapp projects?
Your code should be in src/main/java
. If it doesn't exist already, create it, and then pick Maven -> Update Project from the context menu on the project.
You'll then see src/main/java
alongside src/main/resources
. Right click that, select New -> Package, and it should appear as you'd expect.
Maven won't compile sources under src/main/resources
, which is why your code needs to be in src/main/java
. The src/main/resources
directory is for files that you want to appear on your classpath, which don't need to be compiled. You might put properties files there, for example.
Edit: The reason that 'resources' folders aren't shown in the usual layout in Package Explorer is that m2e sets up resource folders in a different way to source folders. For an explanation of why it does that, see: Maven/Eclipse: The default build path for resources excluded everything
I have solved this issue by below steps:
Now you can see below in all type of Explorers (Package or Project or Navigator)
src/main/java
src/main/resources
src/test/java
src/main/webapp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With