Change Maven Archetype after a project is created in Eclipse?

Archetypes are just used to create a project (ie initialize configuration, source folders, ...) and are not used after that. So if you want to change your project nature you've to do it "by hand".

It seems that in your case, you just have to change in pom.xml, the package type to war and to proceed a "Maven update project" in your IDE so maven plugin will update configuration.


I recently googled and got stumbled upon this post. I have got a way to generate the web.xml and the directory structure for a web application using Eclipse IDE. Before I share that, let's clarify the Eclipse I am using (this feature may not be there in case you are using any older version).

enter image description here

I assume you created the Maven Project with maven-archetype-quickstart as posted by OP. It is basically a jar application. We want to change this to a web application. Here is the process:

  1. Right-click the project > Properties > Project Facets
  2. Select Convert to faceted form...
  3. Tic the Dynamic Web Module and Java boxes. You may want to select the version you need, make sure these are compatible. I selected version 3.0 for Dynamic Web Module (the servlet spec) and Java 1.8.

enter image description here

  1. Now click Apply and Close. This will generate many things in your project.
  2. Now switch to Web perspective if you're not already in. You can do that by following: Window > Perspective > Open Perspective > Other > Web
  3. Now you will be able to see what changes we made to project structure in step 4. It has created the directory structure required for web applications. But still web.xml file is not yet generated. We will do it next.
  4. Right-click on Deployment Descriptor : <your project name> > Generate Deployment Descriptor Stub. It will generate the web.xml file.

enter image description here

  1. Finally change the packaging in pom.xml from jar to war:<packaging>war</packaging>
  2. Now you are ready to go. Since I was working with spring-boot and it requires the webapp folder instead of WebContent, I manually renamed it and moved it inside src\main and then added the webapp as a source folder.

So basically, we have to do this all manually. I just made Eclipse do little bit of work here.