• maven项目打包发布到私有仓库


    在项目开发中通常会引用其他的jar,怎样把自己的项目做为一个jar包的形式发布到私服仓库中,主要有以下三个步骤

    (怎样配置maven私服仓库,就不再这里说明了,可以参考以前的文章)1.在maven的setting.xml中配置用户名和密码:

    <servers>
        <server>
            <username>admin</username>
            <password>admin123</password>
            <id>nexus-release</id>
        </server>
        <server>
            <username>admin</username>
            <password>admin</password>
            <id>nexus-snapshots</id>
        </server>
    </servers>
    注意:要在nexus中打开相应的snapshots和releases仓库中的允许发布的开关

    2.在发布的项目中配置pom.xml 

    如果有parent只需在parent中的pom.xml中配置,没有则在本项目的pom.xml配置即可
    <distributionManagement>
    <repository>
    <id>nexus-release</id>
    <url>http://192.168.0.247/nexus/content/repositories/releases/</url>
    </repository>
    <snapshotRepository>
    <id>nexus-snapshots</id>
    <url>http://192.168.0.247/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
    </distributionManagement> <!--上传source.jar 非必须 -->
    <build>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <executions>
    <execution>
    <id>attach-sources</id>
    <goals>
    <goal>jar</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>

    3.在依赖的项目添加依赖(注意版本是snapshot还是release)

    snapshot版本还是release版本取决于发布项目中的配置

    例如

    <properties>
    <!-- 依赖的版本定义 -->
    <mes.version>0.0.1-RELEASE</mes.version>
    </properties>
    <dependencies>
    <!-- 系统消息服务 -->
    <dependency>
    <groupId>com.longda.message</groupId>
    <artifactId>mes-core</artifactId>
    <version>${mes.version}</version>
    <type>jar</type>
    <scope>compile</scope>
    </dependency>

    </dependencies>

    相应的待发布项目中配置如下

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.longda.message</groupId>
    <artifactId>mes-core</artifactId>
    <version>0.0.1-RELEASE</version>
    <packaging>jar</packaging>
    <name>mes-core</name>
    <url>http://maven.apache.org</url>
    <properties>
    <project.release.version>0.1-RELEASE</project.release.version>

    </dependencies>

    注意:简而言之就是两边的版本一定要对应上,至于是发布snapshot版本还是release版本需要在第二步中指定

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    python爬虫,scrapy,获取响应的cookie,获取返回的cookie
    this指向
    闭包的10种形式
    nodejs 公私钥文件加密解密
    mysql基础知识
    nodejs 连接mysql 集群,开启事务,事务回滚封装
    pm2 启动eggjs,
    js身份证验证,二代身份证,大陆,权重验证,正规
    nodejs限制IP一段时间内的访问次数
    nodejs链接mysql集群,nodejs PoolCluster : Error: Too many connections
  • 原文地址:https://www.cnblogs.com/weiguo21/p/4823981.html
Copyright © 2020-2023  润新知