创建maven-web项目:
dos进入workspace目录:
D:\workspace>mvn archetype:create -DgroupId=org.sonatype.mavenbook.ch06 -DartifactId=simple-parent -
DpackageName=pom -DarchetypeArtifactId=maven-archetype-parent
1、对于web项目,引入servlet的依赖
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.4_spec</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
2、对于web项目发布maven插件:jetty
<build>
[.....]
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
</plugin>
</plugins>
[.....]
</build>
运行命令:mvn jetty:run (注意先打包:mvn cleean install)
===============================================
maven 命令:
mvn clean 清除
mvn install 安装 到创库
mvn package 打包成jar
mvn test 执行测试
mvn -U compile 强制更新并编译(记得常用,特别是在刚上传第三方jar后强制更新)
mvn compile 编译
mvn dependency:analyze 依赖分析
mvn dependency:tree 列出项目中所有的直接和传递性依赖。
mvn test -Dmaven.test.failure.ignore=true 忽略测试失败
mvn install -Dmaven.test.skip=true 安装并跳过测试
mvn help:effective-pom 查看有效pom
mvn assembly:assembly 构建装配(需要配插件)
=====================================
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
=====================================