前面两篇是对maven的基础的介绍,这一篇更侧重于实际的运用
现象:
[INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- mvn test -Dmaven.test.skip=true:跳过单元测试实际上maven-surefire-plugin是maven内置的,但是如果想设置某些符合条件的类才进行test或者是否执行test时,就需要配置该插件了 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.7.1</version> <configuration> <skipTests>true</skipTests> <includes> <include>**/*Tests.java</include> </includes> <excludes> <exclude>**/*ServiceTest.java</exclude> <exclude>**/TempDaoTest.java</exclude> </excludes> </configuration> </plugin>此时并没有真正意义上引入该依赖,可以理解为声明了一个依赖,然后在子工程dependencies里面加上这个依赖,坐标元素为父pom中的坐标元素删掉version。
<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> </dependency> </dependencies>方式二:参数化 在父pom中配置properties标签,且写死版本号,且在dependencyManagement标签中注明,子pom中引入即可 父pom:
<project> <properties> <EREAD.CLASS.VERSION>V300R003C20B311-SNAPSHOT</EREAD.CLASS.VERSION> <JDK.VERSION>1.6</JDK.VERSION> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>com.myproject</groupId> <artifactId>eread.glass</artifactId> <version>${EREAD.CLASS.VERSION}</version> </dependency> </dependencies> </dependencyManagement> </project>且在父pom中注明module
<modules> <module>eread.glass</module> </modules>子pom
<project> <artifactId>eread.glass</artifactId> <version>${EREAD.CLASS.VERSION}</version> </project>