I've created a Maven project with maven-archetype-quickstart
.
I've started coding and now I want to change the archetype to maven-archetype-webapp
in order to make it a dynamic web project.
How do I achieve this?
Right-click the project > Properties > Project Facets. Select Convert to faceted form...
If you want to change the archetype's files, you will need to contact the author of the archetype and suggest a change. If the archetype is from github.com, for example, you could fork the archetype, make the change, and request a pull. You could also submit a bug/issue report.
If you want a web application, use maven-archetype-webapp, or if you want a simple application use maven-archetype-quickstart. They are useful because you will be able to expand them with no problem. Note that this is in the Eclipse plugin by default (at least it is today).
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:
Convert to faceted form...
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
.Apply and Close
. This will generate many things in your project.Web perspective
if you're not already in. You can do that by following:
Window > Perspective > Open Perspective > Other > Webweb.xml
file is not yet generated. We will do it next.Deployment Descriptor : <your project name>
> Generate Deployment Descriptor Stub. It will generate the web.xml
file.pom.xml
from jar to war:<packaging>war</packaging>
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.
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