是否有用于简单 Servlet (2.5) Web 应用程序的 Maven 2 原型(prototype)?
最佳答案
是webapp的原型(prototype):
mvn archetype:generate -DgroupId=com.acme \
-DartifactId=my-webapp \
-Dversion=1.0-SNAPSHOT \
-DarchetypeArtifactId=maven-archetype-webapp \
-DinteractiveMode=false
这将生成以下结构:
$ tree my-webapp/ my-webapp/ ├── pom.xml └── src └── main ├── resources └── webapp ├── index.jsp └── WEB-INF └── web.xml
Where the web.xml is a Servlet 2.3 web.xml:
$ cat my-webapp/src/main/webapp/WEB-INF/web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
对于 Servlet 2.5 Web 应用程序,将其替换为以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Archetype Created Web Application</display-name>
</web-app>
我不知道 NetBeans 但 Eclipse(更准确地说是 M2Eclipse)依赖于 web.xml
来设置项目方面(因此您需要更改 web.xml
在导入之前,如果您在事实之后更改 web.xml
,Eclipse 将不会更新 web facet)。
关于java - 用于简单 Servlet 应用程序的 Maven 原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2782066/