39

I've two Spring MVC projects in Eclipse, but the web content is in different positions.

In one app it's located under:

/WebContent

In the other app under:

/src/main/webapp

Why that? What's the difference?

Is there any way I can see how each project was created in order to create a new one in the same fashion?

tereško
  • 58,060
  • 25
  • 98
  • 150
user1883212
  • 7,539
  • 11
  • 46
  • 82
  • 15
    The first is recognizable as standard Eclipse project structure and the second is recognizable as standard Maven project structure. In order to work properly with the Maven project, you'd probably need to install a Maven plugin and associate the project with Maven. – BalusC Aug 24 '13 at 00:01
  • 2
    In Eclipse, you can right-click on the Project -> Properties -> Deployment Assembly in order to change the location of the web content – René Winkler Oct 18 '15 at 14:14
  • Alternatively, [have go at the relevant Eclipse configuration files](http://stackoverflow.com/a/3439891/1529709) or [create a link from one folder to the other](http://stackoverflow.com/a/22302893/1529709). – zb226 Nov 12 '15 at 12:14

2 Answers2

28

Project directory structure depends on how it was created and the build tool which you are using.

If you create by selecting File -> New ->Dynamic web project in eclipse, then you find the /WebContent directory.

If it is created using Maven, directory strutcure will be /src/main/webapp.

Please go throuh here for more information on Maven project strutcure.

Sanjeev
  • 425
  • 10
  • 17
  • 6
    For those who want a web project that supports Maven: There are 2 ways to create this: **1**. (a) `File > New > Dynamic Web Project > write Project name > Next > Next > check Generate web.xml deployment descriptor` (b) `Right click on the new project folder > Configure > Convert to Maven Project`. This approach will keep `WebContent`. **2**. `File > New > Maven Project > Next > select maven-archetype-webapp as Artifact Id > Next > add Group Id and Artifact Id > Finish`. This approach will create `webapp` under `src/main`. – ROMANIA_engineer Dec 15 '15 at 10:33
  • @engineer's supplement on the answer is very useful. For those who has no experience on creating Maven project. If you don't choose "maven-archetype-webapp" when you are creating Maven project. You will not get the web project structure in the new created project. – Antony.H Dec 24 '15 at 02:20
1

If someone like me messed up with the project and ended up with both folders but wants to keep the maven structure just disable/re-enable the Dynamic Web Module facet and configure the content directory enter image description here

Finally, delete the WebContent folder.

lainatnavi
  • 1,453
  • 1
  • 14
  • 22