爲pom.xml添加組織,法律和開發人員信息java
<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"> ... <name>simple-weather</name> <url>http://www.sonatype.com</url> <licenses> <license> <name>Apache 2</name> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> <distribution>repo</distribution> <comments>A business-friendly OSS license</comments> </license> </licenses> <organization> <name>Sonatype</name> <url>http://www.sonatype.com</url> </organization> <developers> <developer> <id>jason</id> <name>Jason Van Zyl</name> <email>jason@maven.org</email> <url>http://www.sonatype.com</url> <organization>Sonatype</organization> <organizationUrl>http://www.sonatype.com</organizationUrl> <roles> <role>developer</role> </roles> <timezone>-6</timezone> </developer> </developers> ... </project>
mvn dependency:resolve ----打印出項目的依賴列表web
mvn dependency:tree ---打印整個項目的依賴樹apache
mvn install -X ---調試運行標記app
測試範圍依賴是一個只在測試編譯和測試運行在classpath中的有效依賴。若是項目是以war或ear形式打包的,測試範圍依賴就不會被包含在項目打包的輸出中。要添加一個測試依賴範圍,在dependencies中添加<scope>test</scope>便可。<scope>provided</scope>代表這個jar包已由容器提供,不須要打包到lib中。webapp
mvn test ---執行測試maven
從命令行運行mvn test使Maven執行到test階段爲止的全部生命週期階段。Maven Surefire插件有一個test目標,該目標綁定在了test階段。test目標執行項目中全部能在src/test/java找到的而且文件名與**/*Test*.java或***/*TestCase.java匹配的全部單元測試。在Maven Surefire插件執行Junit測試的時候,會在target/surefire-reports目錄下生成XML和常規文本報告。ide
忽略單元測試失敗單元測試
<project> ... <build> <plugins> <plugin> <goupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <testFailureIgnore>true</testFailureIgnore> </configuration> </plugin> </plugins> </build> ... </project>
mvn test -Dmaven.test.failure.ignore=true ---忽略失敗的單元測試測試
mvn install -Dmaven.test.skip=true ---跳過單元測試ui
<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skip>true</skip> <configuration> </plugin> </plugins> </build> ... </project>
Maven Assembly插件是一個用來建立你應用程序特有分發包的插件。能夠使用Maven Assembly插件以你但願的任何形式來裝配輸出,只需定義一個自定義的裝配描述符。
<project> ... <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies-</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins> </build> ... </project>
mvn install assembly:assembly ---構建裝配
配置Jetty插件
<project> ... <build> <fileName>simple-webapp</fileName> <plugins> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> </plugins> </build> ... </project>
mvn jetty:run ---在jetty servlet容器中啓動web應用