Maven仓库

来源:互联网 发布:国内大数据应用案例 编辑:程序博客网 时间:2024/05/17 08:41
  1. 本地仓库
    (1)路径
    在setting.xml中设置:
<setting>    <localRepository>path</localRepository> </setting>

默认地址为~/用户/.m2/repository
2. 远程仓库
这里写图片描述
(1). 私服
私服一般使用nexus系统搭建,阿里云的maven镜像就是使用nexus搭建的。
- 私服的搭建(以阿里云centos坏境示范)

  • 下载安装包
    下载地址http://www.sonatype.org/downloads/nexus-2.1.2-bundle.tar.gz
    我使用的是版本比较老的nexus,其他版本可以自行搜索下载
  • 解压(可以现在本地win解压好,并且配置好在推向centos)
    解压后得到nexus-2.1.2-bundle文件夹,改文件夹中包括nexus-2.1.2、sonatype-work两个文件夹。我们要修改的配置是~\nexus-2.1.2-bundle\nexus-2.1.2\bin\jsw\linux-x86-64下的nexus文件,修改内容如下
NEXUS_HOME=/home/nexus/nexusPLATFORM=linux-x86-64PLATFORM_DIR="${NEXUS_HOME}/bin/jsw/${PLATFORM}"WRAPPER_CMD="${PLATFORM_DIR}/wrapper" WRAPPER_CONF="${PLATFORM_DIR}/../conf/wrapper.conf" PIDDIR="${NEXUS_HOME}"RUN_AS_USER=root
  • 将修改好的安装包推送到centos中的/home文件夹中(本人使用的是filezilla软件,在此也推荐大家使用filezilla界面

  • \home\nexus-2.1.2-bundle\nexus-2.1.2\bin\jsw\linux-x86-64下的nexus文件拷贝到\etc\init.d文件夹中

>cp \home\nexus-2.1.2-bundle\nexus-2.1.2\bin\jsw\linux-x86-64\nexus \etc\init.d\nexus
  • 增加nexus服务检查
>chkconfig –add nexus
  • 启动nexus
>service nexus start

至此,nexus搭建完毕,打开地址:yourhost:8081\nexus,如果你能看到Nexus欢迎界面,恭喜你,说明你搭建成功了。登录名和密码默认为admin/admin123
Nexus欢迎界面
– 私服的使用

  • 本地mavnen私服地址配置(setting.xml)
<setting>....<profiles>   <project>        <repositories>            <repository>                <id>naxus</id>                <name>naxus</name>                <url>yourhost/nexus/content/groups/public/</url>                <releases>                    <enabled>true</enabled>                </releases>                <snapshots><enabled>true</enabled></snapshots>            </repository>        </repositories>        <plusinRepositories>            <plusinRepository>                <id>naxus</id>                <name>naxus</name>                <url>yourhost/nexus/content/groups/public/</url>                <releases><enabled>true</enabled></releases>                <snapshots><enabled>true</enabled></snapshots>            </plusinRepository>        </plusinRepositories>    </project>  </profiles>  <activeProfiles>    <activeProfile>nexus</activeProfile>  </activeProfiles>....<setting>
  • 验证可用性
    写一个helloword文件打包成jar文件然后上传至私服(要登录哦)。
    首先选择Nexus左侧的Repositroies选项
    这里写图片描述
    然后选择3rd party->Artifact Upload,GAV Definition我们选择GAV Parameters
    这里写图片描述
    Group、Artifact、Version按照自己的情况填写即可,packaging自然选择的是jar啦。然后点击Select Artifact to Upload选择刚才生成的jar包。
    然后在左侧所搜关键词,可以使用你的Artifact 进行搜索。
    这里写图片描述
    将xml复制到你的maven项目中,等编译器加载完后没有显示错误就表明整个流程结束了。
1 0
原创粉丝点击