参照:https://www.jianshu.com/p/98a141701cc7

第一阶段 :配置github

1、创建mvn-repo分支    

首先在你的github上创建一个maven-repo-demo仓库,这个最后将作为实际上jar包发布的仓库

2、设置真实姓名    

在github的个人设置中,设置好自己的姓名 。这个环节很重要,若不设置姓名,会出现一些一些意想不到的错误,如:

    [ERROR] Failed to execute goal com.github.github:site-maven-plugin:0.12:site (default) on project rfcore: Error creating commit: Invalid request.
[ERROR] For 'properties/name', nil is not a string.
[ERROR] For 'properties/name', nil is not a string. (422)
[ERROR] -> [Help 1]

第二阶段:配置部署jar到本地1、 配置本地mvn服务

1、设置本地maven的配置文件settings.xml,找到其中的servers 标签,加入如下 配置:

        <server>
<id>github</id>
<username>*****</username>
<password>*****</password>
</server>

2、修改pom文件发布本地仓库   

在需要发布的项目中的pom文件里的 标签下加入以下插件:

然后运行 mvn clean deploy 命令,即可在对应项目中的target/repository目录下找到本地的jar

        <build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/repository</altDeploymentRepository>
</configuration>
</plugin>
</plugins>
</build>

第三阶段:发布jar到远程github上

1、修改pom文件,在properties 中添加下列属性

        <properties>
<github.global.server>github</github.global.server>
</properties>

2、添加修改插件

        <build>
<plugins>
<!--打包插件-->
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/repository</altDeploymentRepository>
</configuration>
</plugin> <!--源码-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin> <!--github上传插件,用于修改后的发布,执行 mvn clean deploy 自动打包上传到github-->
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version >0.12</version>
<configuration>
<message >Maven artifacts for ${project.version}</message>
<noJekyll>true</noJekyll>
<!--本地jar地址-->
<outputDirectory>${project.build.directory}/repository</outputDirectory>
<!--分支-->
<branch>refs/heads/master</branch>
<merge>true</merge> <includes>
<include>**/*</include>
</includes>
<!--对应github上创建的仓库名称 name-->
<repositoryName>maven-repo-demo</repositoryName>
<!--github 仓库所有者 不是账号-->
<repositoryOwner>l305170891</repositoryOwner>
</configuration> <executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin> </plugins>
</build>

再次执行 mvn clean deploy命令即可发布到github上了 。

若出现如下错误请完成第一阶段第二步配置:

    [ERROR] Failed to execute goal com.github.github:site-maven-plugin:0.12:site (default) on project rfcore: Error creating commit: Invalid request.
[ERROR] For 'properties/name', nil is not a string.
[ERROR] For 'properties/name', nil is not a string. (422)
[ERROR] -> [Help 1]

第四阶段:在项目中使用发布到github上的jar包pom文件中添加github仓库

然后添加依赖即可

        <dependency>
<groupId>com.luojian.github.repo.demo</groupId>
<artifactId>maven-repo-demo</artifactId>
<version>1.0.1</version>
</dependency>

将自定义jar包上传github并制作成maven仓库的更多相关文章

  1. 构建自己的jar包上传至Mvaen中央仓库和版本更新

    构建自己的jar包上传至Mvaen中央仓库和版本更新 一直羡慕别人制造轮子,开源项目,供别人使用:我也想这样,可以自己才疏学浅,本次就将自己写小工具上传到Maven的中央仓库. 一步一步详细教程演示如 ...

  2. Maven中安装本地Jar包到仓库中或将本地jar包上传

    摘要 maven install 本地jar 命令格式 mvn install:install-file -DgroupId=<group_name> -DartifactId=<a ...

  3. 用eclipse怎样将本地的项目打成jar包上传到maven仓库

    使用maven的项目中,有时需要把本地的项目打成jar包上传到mevan仓库. 操作如下: 前提:pom文件中配置好远程库的地址,否则会报错 1.将maven 中的settings文件配置好用户名和密 ...

  4. maven jar包上传到服务器

    maven jar包上传到服务器时出现pom文件没有上传上去,致使该jar包再被使用的时候没有依赖,jar包调用出错 解决办法,将pom文件一起deploy上去 mvn deploy:deploy-f ...

  5. nexus搭建maven私服及私服jar包上传和下载

    nexus搭建maven私服及私服jar包上传和下载 标签: nexus管理maven库snapshot 2017-06-28 13:02 844人阅读 评论(0) 收藏 举报 分类: Maven(1 ...

  6. Apache Flink任意Jar包上传导致远程代码执行漏洞复现

    0x00 简介 Apache Flink是由Apache软件基金会开发的开源流处理框架,其核心是用Java和Scala编写的分布式流数据流引擎.Flink以数据并行和流水线方式执行任意流数据程序,Fl ...

  7. IDEA如何将写好的java类(UDF函数)打成jar包上传linux

    一.编写一个UDF函数,实现将字符串大写转小写 import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; ...

  8. Apache Flink Dashboard未授权访问导致任意Jar包上传漏洞

    漏洞危害 攻击者无需Flink Dashboard认证,通过上传恶意jar包 csdn-[漏洞复现]Apache Flink任意Jar包上传导致远程代码执行 freebuf-Apache Flink ...

  9. nexus的jar包上传与下载

    1. hosted,宿主仓库,部署自己的jar到这个类型的仓库,包括releases和snapshot两部分,Releases公司内部发布版本仓库. Snapshots 公司内部测试版本仓库 2. p ...

随机推荐

  1. EFK项目操作(待完善)

    Environment:{ 三台服务器均安装 kafka  zookeeper filebeat logstash kibana } 一.首先安装zookeeper,kafka,让机器有 leader ...

  2. LeetCode 1027. Longest Arithmetic Sequence

    原题链接在这里:https://leetcode.com/problems/longest-arithmetic-sequence/ 题目: Given an array A of integers, ...

  3. WinDbg常用命令系列---!peb

    !peb 简介 !peb显示进程环境块(PEB)中信息的格式化视图. 使用形式 !peb [PEB-Address] 参数 PEB-Address要检查其PEB的进程的十六进制地址.(这不是从进程的内 ...

  4. 关于System.MissingMethodException异常

    什么是MissingMethodException 试图动态访问不存在的方法时引发的异常. 继承 Object Exception SystemException MemberAccessExcept ...

  5. nexus 3.17.0 做为golang 的包管理工具

    nexus 3.17.0 新版本对于go 包管理的支持是基于go mod 的,同时我们也需要一个athens server 然后在nexus 中配置proxy 类型的repo 参考配置 来自官方的配置 ...

  6. 防火墙firewalld

    增加外部可访问的端口 启动: systemctl start firewalld 查看状态: systemctl status firewalld 停止: systemctl stop firewal ...

  7. SVN 常用 还原项目

    1.先修改本来两个文件,然后再提交到SVN 2.在日志界面,查看提交的文件,找到对应的版本号 3.找到对应的版本号(这里的版本号是1995,我提交生成的版本号 的前一个版本 才是我未作出修改的版本), ...

  8. 【洛谷P5019】铺设道路

    题目链接 众所周知,这道题和积木大赛是同一道题 题意就是给出一段自然数序列,每次操作\((L,R)\)把区间\([L,R]\)的数全部减一,不允许出现负数,问把序列变为零的最小操作次数 贪心做法 样例 ...

  9. element ui,input框输入时enter健进行搜索

    <el-form-item label="企业名称"> <el-input v-model="formSearch.kw" @keyup.en ...

  10. java 优秀开源项目

    一.https://github.com/zhangdaiscott/jeecg-boot 简介:一款基于代码生成器的JAVA快速开发平台!全新架构前后端分离:SpringBoot 2.x,Ant D ...