简单介绍:
maven2是一个很好的构建和包管理工具,如果单单用最简单的包依赖管理就可以让你感觉如沐春风。
不多话,把我自己学习maven2的心得和大家分享下。当然自己也是刚学,了解不多。
Eclipse maven插件就不说了。
maven2安装好后,修改配置mirror就可以定义自己的maven2依赖包管理库,localRepository 可以设置将包存放到哪个目录下。
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ~/.m2/repository-->
<localRepository>D:/repository/mvn2</localRepository>
....
<mirror>
<id>US Nexus</id>
<name>US Nexus Public Mirror</name>
<url>http://rttoolsut**:8080/nexus/content/groups/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
....
mirror可以配置多个,经过不完全测试好像在添加Dependence的时候好像是从最下面配置的mirror开始搜索索引。
配置自己的maven2代理服务器:
推荐使用Nexus,安装好,设置几个仓库的config(Apache Snapshots,Maven Central,Releases),设置成Download Remote Indexes -- true.执行reindex.会重构索引。
在Eclipse中配置index,地址就是repository代理的中心库,并且执行reIndex或者updateIndex就可以从远端的代理服务器中重建索引。能实现搜索的功能。
发布自己的jar包
只需要在pom文件中写一个标签
<distributionManagement>
<repository>
<id>releases</id>
<url>http://****:8080/nexus/content/repositories/releases</url>
</repository>
</distributionManagement>
运行cmd到工程目录,执行mvn clean deploy他会自动打包到你这里配置的远端代理库中,包的位置由你的groupId和artifactId决定。