您的位置:首页 > 其它

使用Nexus配置Maven私有仓库

2015-08-14 21:40 656 查看
1. 下载Nexus

下载地址:http://nexus.sonatype.org/

2. 启动Nexus

nexus-2.0.6-bundle/nexus-2.0.6/bin/jsw/linux-x86-64/nexus 启动

3. 进入Nexus管理页面
http://localhost:8081/nexus/index.html
默认密码 admin admin123

点击Repositories ,可以看到仓库列表,包括下面几种:

Public Repositories 仓库组
3rd part 三方库,可以上传jar包到这个仓库
Central maven中心仓库
Releases 自己项目中发布的构建
Snapshots trunk 下开发一个项目

这里需要注意把Central 仓库的自动更新设置为True:



更新之后能看到Index:



4. 在settings.xml中使用本地仓库:

~/.m2 下新建settings.xml :

Xml代码


<profile>
<id>dev</id>
<repositories>
<repository>
<id>nexus</id>
<url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>

<pluginRepository>

<id>nexus</id>

<url>http://127.0.0.1:8081/nexus/content/groups/public</url>

<releases>

<enabled>true</enabled>

</releases>

<snapshots>

<enabled>true</enabled>

</snapshots>

</pluginRepository>

</pluginRepositories>

</profile>
</profiles>

<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>


方式二

<profile>
<id>dev</id>
<activation>
<jdk>1.7</jdk>
</activation>
<repositories>
<repository>
<id>devRepos</id>
<name>dev Repository</name>
<url>http://127.0.0.1:8081/nexus/content/repositories/devRepos/</url>
<layout>default</layout>
</repository>
</repositories>
</profile>


现在可以通过maven实验一下:

mvn archetype:create -DgroupId=com.yourcompany -DartifactId=myproject -DarchetypeArtifactId=maven-archetype-webapp

lvkun@lvkun-duitang:~/workspace$ mvn archetype:create -DgroupId=com.yourcompany -DartifactId=myproject -DarchetypeArtifactId=maven-archetype-webapp
[INFO] Scanning for projects...
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom (5 KB at 27.2 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom (13 KB at 409.6 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/maven-parent/16/maven-parent-16.pom Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/maven-parent/16/maven-parent-16.pom (23 KB at 463.8 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/apache/7/apache-7.pom Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/apache/7/apache-7.pom (15 KB at 563.7 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar (23 KB at 459.9 KB/sec)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: