参照: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. Centos7安装Hive2.3

    准备 1.hadoop已部署(若没有可以参考:Centos7安装Hadoop2.7),集群情况如下: hostname IP地址 部署规划 node1 172.20.0.4 NameNode.Data ...

  2. Python微信操控(itchat)

    itchat是一个开源的微信个人号接口,使用python调用微信从未如此简单. 开源地址 https://github.com/littlecodersh/ItChat 文档: https://itc ...

  3. 洛谷 P3388 【模板】割点(割顶)题解

    今天学了割点,就A了这道板子,比较难理解的地方就在于如果是根节点就要找两个点来满足low[y]>=dfn[x],如果不是就只需找一个点来满足.Tarjan(i,i)中第一个i是开始搜索的点而第 ...

  4. react基本语法及组件

    一.react简介 1.起源:React 起源于 Facebook 的内部项目,用来架设 Instagram 的网站,并于 2013 年 5 月开源. 2.特点: 1.声明式设计 −React采用声明 ...

  5. H5 利用vue实现图片上传功能。

    H5的上传图片如何实现呢? 以下是我用vue实现的图片上传功能,仅供参考. <!DOCTYPE html> <html> <head> <meta chars ...

  6. am335x system upgrade kernel ethernet(四)

    1      Scope of Document This document describes ethernet hardware design and porting KZS8081 to ubo ...

  7. 特征的非线性变换(Feature Non-linear Transformation)

    有时候特征x和目标y不呈线性关系,线性模型y=wx+b不能很好地反映事物的规律或者无法对事物进行有效分类,因此此时我们需要使用非线性模型. (x=([x1,x2,...,xn])T,w=([w1,w2 ...

  8. JavaScript高级程序编程(二)

    JavaScript 基本概念 1.区分大小写,变量名test与Test 是两个不同的变量,且函数命名不能使用关键字/保留字, 变量命名规范: 开头字符必须是字母,下划线,或者美元符号,ECMAScr ...

  9. 意图Intent

    意图点击官方链接 前言 对意图Intent,学习安卓需掌握.以官方链接:http://www.android-doc.com/reference/android/content/Intent.html ...

  10. Hash算法解决冲突的四种方法

    Hash算法解决冲突的方法一般有以下几种常用的解决方法 1, 开放定址法: 所谓的开放定址法就是一旦发生了冲突,就去寻找下一个空的散列地址,只要散列表足够大,空的散列地址总能找到,并将记录存入 公式为 ...