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).
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:
- Right-click the project > Properties > Project Facets
- Select
Convert to faceted form...
- Tic the
Dynamic Web Module
andJava
boxes. You may want to select the version you need, make sure these are compatible. I selected version3.0
forDynamic Web Module
(the servlet spec) andJava 1.8
.
- Now click
Apply and Close
. This will generate many things in your project. - Now switch to
Web perspective
if you're not already in. You can do that by following: Window > Perspective > Open Perspective > Other > Web - 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. - Right-click on
Deployment Descriptor : <your project name>
> Generate Deployment Descriptor Stub. It will generate theweb.xml
file.
- Finally change the packaging in
pom.xml
from jar to war:<packaging>war</packaging>
- Now you are ready to go. Since I was working with
spring-boot
and it requires thewebapp
folder instead ofWebContent
, I manually renamed it and moved it insidesrc\main
and then added thewebapp
as asource folder
.
So basically, we have to do this all manually. I just made Eclipse do little bit of work here.