zoukankan      html  css  js  c++  java
  • Maven基础配置—上传jar包到私服

     

    一、配置

    在需要上传的工程中的pom.xml文件中加入下面的配置

    <distributionManagement>
        <repository>
            <id>release</id>
            <name>Release Repository</name>
            <url>http://ip/nexus/content/repositories/releases</url>
        </repository>
        <snapshotRepository>
            <id>snapshot</id>
            <name>Snapshot Repository</name>
            <url>http://ip/nexus/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    我们可以在settings.xml中配置全局的url地址,pom.xml中进行动态获取。

    settings.xml的default-profile中加入下面全局配置

    <properties>
        <ReleaseRepository>http://ip/nexus/content/repositories/releases</ReleaseRepository>
        <SnapshotRepository>http://ip/nexus/content/repositories/snapshots</SnapshotRepository>
    </properties>

    pom.xml中改为

    <distributionManagement>
        <repository>
            <id>release</id>
            <name>Release Repository</name>
            <url>${ReleaseRepository}</url>
        </repository>
        <snapshotRepository>
            <id>snapshot</id>
            <name>Snapshot Repository</name>
            <url>${SnapshotRepository}</url>
        </snapshotRepository>
    </distributionManagement>

    这样,pom.xml中就可以动态获取settings.xml中的地址

    除此之外,还要在settings.xml中配置鉴权账号,否则上传将报401鉴权错误

    <server>
        <id>deployment</id>
        <username>deployment</username>
        <password>deployment账号的密码</password>
    </server>

     

    二、命令

    mvn deploy:deploy-file -DgroupId=groupId -DartifactId=artifactId -Dversion=version -Dfile=本地jar包路径 -DrepositoryId=releases/snapshots -Durl=仓库地址

    举例:上传jmxri-1.2.1.jar,本地存放在D盘

    mvn deploy:deploy-file -DgroupId=com.sun.jmx –DartifactId=jmxri -Dversion=1.2.1 -Dfile=d:/jmxri-1.2.1.jar -DrepositoryId=releases -Durl=http://ip/nexus/content/repositories/releases

  • 相关阅读:
    Action<T>和Func<T>的使用(转)
    javascript将网页表格导出Word(转载)
    jQuery扩展方法2(转载)
    Microsoft SQL Server 2008 安装说明
    INSERT INTO 语句的语法错误 access 保留字段
    .NET 验证控件
    TFS强制撤销用户的签出
    .net 操作XML
    TFS 恢复删除文件
    checkboxlist详细用法、checkboxlist用法、checkboxlist
  • 原文地址:https://www.cnblogs.com/bigshark/p/5137354.html
Copyright © 2011-2022 走看看