Maven 創建web項目
假設在D:\mavne\WebApp1 目錄下執行命令
mvn archetype:create -DgroupId=com.mycompany.webapp -DartifactId=myweb -DarchetypeArtifactId=maven-archetype-webapp
得
<body>
<h2>Hello World!</h2>
</body>
</html> 這就將在后面通過瀏覽器看到了內容 進入 ..\myweb 目錄下,執行mvn install 命令
如果想要用jetty發布,修改pom.xml,修改后如下
<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.mycompany.webapp</groupId>
<artifactId>myweb</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>myweb Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>myweb</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
</plugin>
</plugins>
<!-- 添加以上6行插件配置代碼 -->
</build>
</project>
執行運行 mvn jetty:run 直接部分在jetty下(第一次很慢),
利用 http://localhost:8080/myweb/
</span>