Maven基础使用

第一章=>

1、配置阿里云

2、搭建私服

****************************************************************************************************************************************************************************

复制代码
1、Maven仓库指向阿里云
#(1)Maven的优点和概述
# 在多个开发团队环境时,Maven可以设置按标准在非常短的时间里完成配置工作。由于大部分项目的设置都很简单,并且可重复使用,Maven让开发人员的工作更轻松
# 1.项目对象模型是pom
# 2.坐标两个Id和一个version
# 3.依赖管理:传递,可选,排除依赖
# 4.仓库管理
# 5.生命周期:三个生命周期
# 6.插件和目标路径在仓库里
#(2)Settings.xml里设置本地依赖仓库路径
<localRepository>C:/IT/Repository</localRepository>
<mirror>
	<id>nexus-aliyun</id>
	<mirrorOf>central</mirrorOf>
	<name>Nexus aliyun</name>
	<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
# 下载Maven
链接:https://pan.baidu.com/s/16_-IayuGRTtsBnitusGYgg 
提取码:HIT0

****************************************************************************************************************************************************************************

复制代码
2、Maven搭建私服
(1)下载nexus
链接:https://pan.baidu.com/s/12RUgCIPkKOUpPin1l9AMtw 
提取码:HIT0
# 放到/opt目录 cd/opt
# tar -zxvf nexus-2.14.8-01-bundle.tar.gz 
# cd /opt/nexus-2.14.20-02/bin
# vim nexus
# RUN_AS_USER=  修改为:RUN_AS_USER=root
# ./nexus start
# 开放8081端口
# http://wdfgdzx.top:8081/nexus
# 点击右上角登录,默认用户名,密码:admin/admin123,然后点击profile可以修改密码
(2)上传本次jar包到私服
# 点击Repositories-Central-Configuration-Download Remote Indexes 设置为True
# Releases-Deployment Policy-Allow ReDeploy
# 3rd party-Artifcat upload- select ...upload
# 通过ftp将本地仓库jar传到/opt/sonatype-work/nexus/storage/thirdparty目录
# 3rd party上右键点击Repair Index
# Public Repositories ,点击Refresh按钮,就可以看到本地仓库上传到私服了
(3)配置从远程仓库从阿里云
# Nexus 默认远程仓库为 https://repo1.maven.org/maven2/
# Repositories-Add-Proxy Repository-输入
Repository ID: aliyun 
Repository Name: Aliyun Repository 
Remote Storage Location: http://maven.aliyun.com/nexus/content/groups/public/
# Public Repositories ,点击Refresh按钮,并把 aliyun 排在 central 之上,左右移动即可实现
(4)Setting.xml配置
	<server>
        <id>releases</id>
        <username>admin</username>
        <password>admin2021</password>
    </server>
    <server>
        <id>snapshots</id>
        <username>admin</username>
        <password>admin2021</password>
    </server>
----------
<mirror>
          <id>nexus</id>
          <mirrorOf>central</mirrorOf>
          <url>http://wdfgdzx.top:8081/nexus/content/groups/public/</url>
</mirror>
-------------
 <profile>
           <id>nexus</id>
                <repositories>
                    <!-- 私有库地址-->
                    <repository>
                        <id>central</id>
                        <url>http://wdfgdzx.top:8081/nexus/content/groups/public/</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                    </repository>
                </repositories>      
                <pluginRepositories>
                    <!--插件库地址-->
                    <pluginRepository>
                        <id>central</id>
                        <url>http://wdfgdzx.top:8081/nexus/content/groups/public/</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                       </snapshots>
                    </pluginRepository>
                </pluginRepositories>
    </profile>
----------------------
<activeProfiles>
        <activeProfile>nexus</activeProfile>
  </activeProfiles>
------------------------
(5)pom.xml配置与使用,与dependencies同目录加上以下代码
 <distributionManagement>
        <repository>
            <id>releases</id>
            <name>Nexus Release Repository</name>
            <url>http://wdfgdzx.top:8081/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://wdfgdzx.top:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
------------------------------
    <dependencies>
(5)从私服上传和引入本地包
# 找到私服/opt/sonatype-work/nexus/storage/thirdparty 上传jar包
# 刷新仓库3rd party 放到首位 -清空本地maven缓存-拉去jar包即可,有点问题
(6)单个添加本地包
# 3rd party -Artifact upload-GAV Parameters-输入Group:等信息-add Artifact -upload Artifact 
# 再使用
相关推荐
rannn_11124 分钟前
【苍穹外卖|Day4】套餐页面开发(新增套餐、分页查询、删除套餐、修改套餐、起售停售)
java·spring boot·后端·学习
灵感菇_26 分钟前
Java HashMap全面解析
java·开发语言
qq_124987075328 分钟前
基于JavaWeb的大学生房屋租赁系统(源码+论文+部署+安装)
java·数据库·人工智能·spring boot·计算机视觉·毕业设计·计算机毕业设计
短剑重铸之日34 分钟前
《设计模式》第十一篇:总结
java·后端·设计模式·总结
若鱼19191 小时前
SpringBoot4.0新特性-Observability让生产环境更易于观测
java·spring
觉醒大王1 小时前
强女思维:着急,是贪欲外显的相。
java·论文阅读·笔记·深度学习·学习·自然语言处理·学习方法
努力学编程呀(๑•ี_เ•ี๑)1 小时前
【在 IntelliJ IDEA 中切换项目 JDK 版本】
java·开发语言·intellij-idea
码农小卡拉1 小时前
深入解析Spring Boot文件加载顺序与加载方式
java·数据库·spring boot
向上的车轮1 小时前
为什么.NET(C#)转 Java 开发时常常在“吐槽”Java:checked exception
java·c#·.net
Dragon Wu2 小时前
Spring Security Oauth2.1 授权码模式实现前后端分离的方案
java·spring boot·后端·spring cloud·springboot·springcloud