http://haohaoxuexi.iteye.com/blog/2055745
http://www.yiibai.com/maven/maven_environment_setup.html
http://blog.csdn.net/column/details/mavenaction.html
http://juvenshun.iteye.com/blog/305865
在POM配置Maven plugin提示错误“Plugin execution not covered by lifecycle configuration”的解决方案
http://ljhzzyx.blog.163.com/blog/static/383803122013440345857
Maven 非继承引用
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies
http://blog.csdn.net/zswjob126/article/details/46609273
http://www.infoq.com/cn/news/2011/01/xxb-maven-3-pom-refactoring
Maven 中央仓库
http://search.maven.org/
http://mvnrepository.com/
https://maven.java.net/content/repositories/public/org/
http://repo1.maven.org/maven2/
http://repository.jboss.com/
Maven + nexus
maven安装好默认是没有配置仓库信息,此时maven都默认去远程的中心仓库下载所依赖的构件。既然使用了私服,就需要明确告诉maven去哪里下载构件,可以在三个地方进行配置,分别是是mavne的安装目录下的conf下的settings.xml文件,这个全局配置,再一个是在userprofile/.m2目录下的settings.xml,如果不存在该文件,可以复制conf下settings.xml,这个是针对当前用户的,还有一个是在pom.xml中指定,其只对该项目有效,三个文件的优先级是pom.xml大于.m2,.m2大于conf下
http://blog.csdn.net/kimylrong/article/details/23280155
如何处理下载失败
pom.xml经常就报找不到某某某jar包的错,很烦很头疼。一句话,这个是网络的问题,下载失败。正常情况下jar包存在于三个地方, Local仓库,Nexus私服仓库,镜像或者maven中央仓库。以所列出的顺序为准,搜索的过程由前往后,下载的过程由后往前。下载过程分两段,镜像或者maven中央仓库=>Nexus私服仓库,Nexus私服仓库=>Local仓库,两段都可能出问题。出问题也没事,重试就行了呗,但maven会在Local仓库中生成一份以lastUpdated结尾的破文件,一个错误的缓存(cache)。要能正确重试,只能手动删除缓存。
先判断是哪一段出错,选择Repositories=>Central=>Brower Storage,看一下对应的jar包在Nexus私服上面有没有,没有的话说明镜像或者maven中央仓库=>Nexus私服仓库下载失败,否则Nexus私服仓库=>Local仓库下载失败。
镜像或者maven中央仓库=>Nexus私服仓库下载失败处理方法
删除Local仓库的缓存。打开~/.m2/repository文件夹,删除报错jar包所在的文件夹(也可以只删除特定的子文件,提高效率)。删除Nexus私服仓库的缓存。Repositories=>Central=>Brower Storage,选择对应的目录树,右键先Expire Cache,后Delete。
Nexus私服仓库=>Local仓库下载失败处理方法
这种情况简单很多,只要删除Local仓库的缓存即可。步骤如上。
Nexus 更新索引
1.手动更新
1. 下载索引文件
在http://repo.maven.apache.org/maven2/.index/ 中下载
nexus-maven-repository-index.gz
nexus-maven-repository-index.properties
然后再下载一个indexer-cli-5.1.0.jar
indexer的下载地址:http://maven.outofmemory.cn/org.apache.maven.indexer/indexer-cli/5.1.0/
indexer的Maven
<dependency> <groupId>org.apache.maven.indexer</groupId> <artifactId>indexer-cli</artifactId> <version>5.1.0</version> </dependency>
2. 解压缩索引文件
将上面三个文件(.gz & .properties & .jar)放置到同一目录下,运行如下命令
java -jar indexer-cli-5.1.0.jar -u nexus-maven-repository-index.gz -d indexer
3. 停止nexus
4. 删除原有的索引文件
将{nexus_home}sonatype-work
exusindexercentral-ctx下的文件全部删掉
5. 拷贝索引至central-ctx目录下
将nexus-maven-repository-index.gz解压后的indexer目录中所有文件,放到sonatype-work
exusindexercentral-ctx下面
6. 启动nexus即自动更新索引
2.自动下载
1. 打开Repositories标签,选中远程仓库并打开Configuration,将Download Romote Location 设置为true;
2. 在远程仓库上右键选择Update Index,Nexus会自动建立一条任务计划;一般远程仓库都比较大,构建会比较多,索引文件会很大,像http://repo1.maven.org/maven2 就有几百M,因此需要的时间就比较长。
3. 可以进入Scheduled Tasks查看任务的执行情况,当执行完成时,远程仓库的索引就已经建立完毕了。
两种方式,只要Browse_Index后看到许多文件的话就说明更新成功
私服搭建自建hosted库和中央仓库的配置
在nexus中除了默认的中央仓库等,还有一个新建的 hosted 仓库szc
配置一: Public Repositories中不包含szc仓库,同时 settings.xml 如下配置
<mirrors> <mirror> <!--This sends everything else to /public --> <id>nexus</id> <mirrorOf>*</mirrorOf> <url>http://localhost:8081/nexus/content/groups/public</url> </mirror> <mirror> <id>szc</id> <mirrorOf>*</mirrorOf> <name>szc pqm repository</name> <url>http://localhost:8081/nexus/content/repositories/szc</url> </mirror> </mirrors>
在这种配置下,所有的对构件下载的请求都指向Public Repositories,不会从szc仓库中下载,即使构件在Public Repositories中不存在,但是在szc中存在。
配置二: Public Repositories中包含szc仓库,同时 settings.xml 如下配置
<mirrors> <mirror> <!--This sends everything else to /public --> <id>nexus</id> <mirrorOf>*</mirrorOf> <url>http://localhost:8081/nexus/content/groups/public</url> </mirror> </mirrors>
在这种情况下, 对构件的请求都指向Public Repositories,但是因为szc也在Public Repositories中,所以无论构件属于中央仓库还是属于szc,均能下载。
但是,对于szc中已有(即nexus的szc本地仓库已有),远程中央仓库也有,但是并未下载到nexus的代理中央仓库中(即nexus本地中央仓库没有)还是会从远程中央仓库下载到nexus本地。为什么不从szc中直接下载?对于多仓库的选择策略有待进一步确认。
maven 生命周期
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html