您的位置:首页 > 其它

maven私服的搭建及jar包上传下载

2017-11-17 23:50 393 查看
私服就是公司私自使用的服务器

搭建私服的步骤

          前提:必须有jdk和java_home环境变量.


1.下载私服软件

              地址:https://www.sonatype.com/download-oss-sonatype






2.下载好后解压到一个非空的文件夹下

3.用管理员身份运行cmd.

4.复制新解压后nexus的bin目录路径






5.在cmd窗口中运行命令:[b] 
[/b]

[b]   (1)进入bin目录[/b]

[b]


[/b]

[b](2)执行nexus install进行安装.此时可以在服务中看到nexus服务.是已停止状态.[/b]

[b](3)还是在bin目录下运行nexusstart 启动该服务.[/b]

[b]6.私服管理[/b]

[b]       在...\nexus-2.14.5-02-bundle\nexus-2.14.5-02\conf目录下找到nexus.properties文件[/b]

[b]   


[/b]

[b]    [/b]

访问:http://localhost:8081/nexus   ---->点击右上角“log in”[b]---->[b][b][b][b]输入username:admin 和Password:admin123登录[/b][/b][/b][/b][/b]

[b]7.利用maven下载jar包[/b]

[b][b]   在maven软件中把私服地址配置上.在settings.xml中找到profiles节点进行配置一下代码[/b][/b]



<profiles>
<profile>
<id>dev</id>
<repositories>
<repository>
<!--仓库id,可以配置多个仓库要保证id不重复-->
<id>nexus</id>
<!--仓库地址,也就是我们私服的仓库组地址-->
<url>http://localhost:8081/nexus/content/groups/public/</url>
<!--是否下载releases版本的jar-->
<releases>
<enabled>true</enabled>
</releases>
<!--是否下载snapshots版本的jar-->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!--插件仓库,maven运行时的命令依赖的插件jar包,也从私服下载-->
<pluginRepository>
<id>public</id>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>

</profiles>


8.上传jar包

[b][b]   (1)把自己的包传到私服里,需要配置账号,就是我们开始用的admin/admin123[/b][/b]

[b][b]   (2)[b][b][b]在maven软件的配置文件settings.xml里找到server节点进行设置.[/b][/b][/b][/b][/b]

<!-- 设置发布时的用户名 -->
<servers>
<!-- releases和snapshots表示是上传到正式仓库还是开发仓库 -->
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>


(3)在项目的父项目的pom.xml中增加上传的仓库地址



<!-- 依赖包发布到私服,将开发的包上传到宿主仓库 -->
<distributionManagement>
<!-- 上传到宿主仓库的releases -->
<repository>
<id>releases</id>
<name>Internal Releases</name>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<!-- 上传到宿主仓库的snapshots -->
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>


(4)运行deploy.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  maven jar