1、依赖管理
dependencies即使在子项目中不写该依赖项,那么子项目仍然会从父项目中继承该依赖项(全部继承)
dependencyManagement里只是声明依赖,并不实现引入,因此子项目需要显示的声明需要用的依赖。
2、阿里镜像,修改settings
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
3、聚合与继承
4、maven将本地jar包添加到本地仓库
maven在pom文件里引用本地jar
方法1:
<dependency>
<groupId>org.wltea</groupId>
<artifactId>IKAnalyzer</artifactId>
<version>2012_u6</version>
<scope>system</scope>
<systemPath>E:/repositories/IKAnalyzer2012_u6.jar</systemPath>
</dependency>
mvn install:install-file -Dfile=jar包的位置 -DgroupId=一般是公司名倒序 -DartifactId=唯一型ID -Dversion=版本号 -Dpackaging=jar
执行mvn命令:
下载所有pom依赖包的source:mvn dependency:resolve -Dclassifier=sources
下载指定依赖包的source:mvn dependency:sources -DincludeArtifactIds=guava
其中guava为ArtifactId
5, install 和 package的区别
package will compile your code and also package it. For example, if your pom says the project is a jar, it will create a jar for you when you package it and put it somewhere in the target directory (by default).
install will compile and package, but it will also put the package in your local repository. This will make it so other projects can refer to it and grab it from your local repository.
总的来说:
package = 编译+打包
install = 编译+打包+入本地库,打完包之后能够被其他项目依赖到。
6、编译项目跳过 jacoco 方案: skipTests配置为true,并在terminal执行 mvn clean verify 。