One of the simplest choices to create a Java Web application with Maven is the maven-archetype-webapp
. This archetype provides a minimal skeleton for creating a Web application. To create an application using this archetype in batch mode, you can use the following command:
$ mvn archetype:generate -DgroupId=com.sample -DartifactId=web-project -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
Here is the resulting project:
├── pom.xml └── src └── main ├── resources └── webapp ├── index.jsp └── WEB-INF └── web.xml
Within the webapp
folder, you can add the web pages (JSP/HTML) of your Web application. In the resources
folder you can add all files or libraries that will be included automatically in the Web application’s classpath.
Next, if you are developing a Jakarta EE application for WildFly, it is recommended to include in the pom.xml the following dependencies and the WildFly plugin so that you can deploy directly from the Command Line:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mastertheboss</groupId> <artifactId>jakartaee-example</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>Jakarta EE example project</name> <description>A starter Jakarta EE Project</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format> <version.wildfly.maven.plugin>2.0.0.Final</version.wildfly.maven.plugin> </properties> <dependencies> <dependency> <groupId>jakarta.platform</groupId> <artifactId>jakarta.jakartaee-api</artifactId> <version>8.0.0</version> <scope>provided</scope> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.2.3</version> </plugin> <plugin> <groupId>org.wildfly.plugins</groupId> <artifactId>wildfly-maven-plugin</artifactId> <version>${version.wildfly.maven.plugin}</version> </plugin> </plugins> </build> <profiles> <profile> <id>default</id> <activation> <activeByDefault>true</activeByDefault> </activation> <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.4.3</version> <configuration> <skip>true</skip> </configuration> </plugin> </plugins> </build> </profile> </profiles> </project>