写道
<settings>
<proxies>
<proxy>
<id>normal</id>
<active>true</active>
<protocol>http</protocol>
<username>deployment</username>
<password>deploy</password>
<host>localhost:8081/nexus</host>
<port>80</port>
<nonProxyHosts>localhost:8081/nexus</nonProxyHosts>
</proxy>
</proxies>
<mirrors>
<mirror>
<!--This is used to direct the public snapshots repo in the
profile below over to a different nexus group -->
<id>nexus-public-snapshots</id>
<mirrorOf>public-snapshots</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public-snapshots</url>
</mirror>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>development</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<!--this profile will allow snapshots to be searched when activated-->
<id>public-snapshots</id>
<repositories>
<repository>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>development</activeProfile>
</activeProfiles>
</settings>
<proxies>
<proxy>
<id>normal</id>
<active>true</active>
<protocol>http</protocol>
<username>deployment</username>
<password>deploy</password>
<host>localhost:8081/nexus</host>
<port>80</port>
<nonProxyHosts>localhost:8081/nexus</nonProxyHosts>
</proxy>
</proxies>
<mirrors>
<mirror>
<!--This is used to direct the public snapshots repo in the
profile below over to a different nexus group -->
<id>nexus-public-snapshots</id>
<mirrorOf>public-snapshots</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public-snapshots</url>
</mirror>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>development</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<!--this profile will allow snapshots to be searched when activated-->
<id>public-snapshots</id>
<repositories>
<repository>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>development</activeProfile>
</activeProfiles>
</settings>
settings.xml中的proxies/proxy节点配置的是部署服务器访问属性,deployment/deploy对应的是部署用户名和密 码;mirrors/mirror配置的是maven访问仓库的地址,这里使用的是Nexus提供的群组概念,将多个仓库组成一个public- group的方式进行访问;profiles/profile则主要用来描述仓库部署的访问配置。
Nexus 是Sonatype推出的强大Maven仓库管理器产品,要比以前TSS 上介绍的Artifactory 要好使用的多,也是一个拆箱即用的Java App,内嵌Jetty容器和Java Wrapper做Windows服务,安装简单到解压然后双击install即可。
默认安装后的访问路径为http://localhost:8081/nexus/ , 管理员登录为admin/admin123
登录后最重要的事情就是打开远程索引下载,操作为选 择菜单Administrator->Repositories,然后在右边打开的列表中依次选择type字段为proxy的记录,在下方的编辑区 中修改"Download Remote Indexes"值为true,再从这三个仓库上点右键选择"Re-Index",Re-Index后,Nexus会从后台去官方地址下载仓库索引文件,大概20M大小,根据网速快慢下载相应时间后选择仓库时会以树形目 录的方式显示仓库内容。
- 从浏览器里打开访问地址后,通过"Artifact Search"菜单可以进行构件搜索。
- 对于一些特殊的构件,比如sqlserver2005的jdbc驱动,你可以通过管理员登录然后从第三方上传构件
- 提供仓库组的概念,对于远程代理仓库和本地宿主仓库,还有第三方仓库,全部创建为一个public-group,然后通过访问组就可以访问所有的仓库构件了,这就是所谓的分散存储,统一访问
- 和Maven结合也很简单,首先是要配置Maven,打开$user$/.m2/下的settings.xml(没有的话创建一个),然后拷贝以下内容到文件中
<mirror>
<id>Nexus</id>
<name>Nexus Public Mirror</name>
<url>http://localhost:8081/nexus/content/groups/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
<id>Nexus</id>
<name>Nexus Public Mirror</name>
<url>http://localhost:8081/nexus/content/groups/public</url>
<mirrorOf>central</mirrorOf>
</mirror>