maven入门 (二)_私服安装与上传下载

简介: 本篇文章主要介绍maven的私服安装和 jar包的上传与下载。毕竟大家还是在公司需要上传jar包到自己公司私服的。1.安装私服下载链接: https://pan.baidu.com/s/17dbQny3d1VgKBA529BTwJA 密码: uizp下载完成。

本篇文章主要介绍maven的私服安装和 jar包的上传与下载。毕竟大家还是在公司需要上传jar包到自己公司私服的。

1.安装私服

下载链接: https://pan.baidu.com/s/17dbQny3d1VgKBA529BTwJA 密码: uizp
下载完成。(我的win系统),解压文件

enter image description here

通过系统管理员身份运行cmd,进入nexus-2.12.0-01-bundle\nexus-2.12.0-01\bin目录,运行 nexus install

enter image description here

启动私服,运行 nexus start

enter image description here

访问网址:http://localhost:8081/nexus/#welcome 登录私服:admin/admin123

enter image description here
enter image description here

仓库类型

enter image description here

2.上传

修改maven配置文件
  • 找到你的maven 安装路径如:E:\app\apache-maven-3.5.3\conf
  • 修改setting.xml 文件,放在servers 节点下
    <server>
      <id>releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <server>
      <id>snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
修改项目 pom文件
    <distributionManagement>
        <repository>
            <id>releases</id>
            <url>http://localhost:8081/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
执行deploy命令发布到私服

这里我使用idea 进行发布,最近在使用idea 进行开发,感觉不错

  • 点击"Edit Configurations"
    enter image description here
  • 进入Run/Debug Configurations窗口,点击左上角的"+",在弹出的"Add New Configuration"列表中选择"maven".
    enter image description here
  • 为新的configuration输入名称和执行的命令,点击确认
    enter image description here
  • 配置完成后,新的configuration会成为默认的configuration,直接点击运行按钮--三角形绿色按钮
    http://p7zk4x9pv.bkt.clouddn.com//mavenTIM%E6%88%AA%E5%9B%BE20180519084006.png
  • 执行配置的maven命令
    enter image description here
  • 验证上传成功
    enter image description here

3.下载

修改maven配置文件 setting.xml
  • 配置profile
        <profile>   
        <!--profile的id-->
        <id>dev</id>   
        <repositories>   
          <repository>  
            <!--仓库id,repositories可以配置多个仓库,保证id不重复-->
            <id>nexus</id>   
            <!--仓库地址,即nexus仓库组的地址-->
            <url>http://localhost:8081/nexus/content/groups/public/</url>   
            <!--是否下载releases构件-->
            <releases>   
              <enabled>true</enabled>   
            </releases>   
            <!--是否下载snapshots构件-->
            <snapshots>   
              <enabled>true</enabled>   
            </snapshots>   
          </repository>   
        </repositories>  
         <pluginRepositories>  
            <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
            <pluginRepository>  
                <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
                <id>public</id>  
                <name>Public Repositories</name>  
                <url>http://localhost:8081/nexus/content/groups/public/</url>  
            </pluginRepository>  
        </pluginRepositories>  
      </profile> 
  • 配置activeProfiles
  <activeProfiles>
    <activeProfile>dev</activeProfile>
  </activeProfiles>
查看下载maven语句

enter image description here

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>springbootdemo</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
将上面的代码粘贴到项目pom.xml 中,idea会右下角提示你import changes,点击

enter image description here

验证下载成功

找到你的本地maven仓库
https://yqfile.alicdn.com/img_f206b244e877683dc3a3a1975142873b.png

总结

好了,现在 终于学会上传私服jar包了。我的maven学习 ,就暂时告一段落了。玩的开心

学习不是要么0分,要么100分的。80分是收获;60分是收获;20分也是收获。有收获最重要。但是因为着眼于自己的不完美,最终放弃了,那就是彻底的0分了。
相关文章
|
25天前
|
Java Linux Maven
Linux中安装MAVEN环境配置
Linux中安装MAVEN环境配置
58 3
|
2月前
|
Java Apache Maven
【Maven从入门到如土】Maven 核心程序解压和配置
【Maven从入门到如土】Maven 核心程序解压和配置
59 0
|
3月前
|
存储 IDE Java
Maven的简介与安装
Maven的简介与安装
43 0
|
3月前
|
Java Maven 数据安全/隐私保护
maven发布jar包到私服以及从私服下载jar包的操作
maven发布jar包到私服以及从私服下载jar包的操作
|
4月前
|
Java Maven Windows
Windows 安装 Maven
Windows 安装 Maven
|
4月前
|
存储 Oracle Java
Maven高级-私服简介与安装及私服仓库分类
Maven高级-私服简介与安装及私服仓库分类
62 0
|
2月前
|
Java Maven
【Maven】下载配置maven以及IDEA配置maven详情
【Maven】下载配置maven以及IDEA配置maven详情
125 0
|
25天前
|
Java Maven
maven手动安装jar
maven手动安装jar
20 2
|
26天前
|
Java Linux Maven
linux安装maven
linux安装maven
14 0
|
2月前
|
IDE Java Maven