参照: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. js 对嵌套页面的父页面进行跳转

    window.top.location.href = '/stores';

  2. [Web] About image: MozJPEG

    Image is quite heavy in web traffic. it is about 53% whole web traffic. It is important to make sure ...

  3. jupyter Notebook 设置密码

    由于服务器关闭了图形界面 所以在服务器上安装Jupyter Notebook 随后本机web访问,利用本机的显卡可以执行plt相关图形命令 本次介绍如何设置Jupyter Notebook的密码设定 ...

  4. 特征缩放(Feature Scaling)

    特征缩放的几种方法: (1)最大最小值归一化(min-max normalization):将数值范围缩放到 [0, 1] 区间里 (2)均值归一化(mean normalization):将数值范围 ...

  5. 桥接:JS调用安卓方法报错Uncaught Error: Error calling method on NPObject

    说一说自己粗心踩到的一个不算坑的坑: 项目是安卓webview嵌入SPA单页应用页面,涉及到JS调用原生安卓方法,但就是在调用安卓方法时死活一直报错xxx  NPObject一堆错误.写了一个测试页面 ...

  6. Automatic Ship Detection in Optical Remote Sensing Images Based on Anomaly Detection and SPP-PCANet

    基于异常检测和 PCANet 的船舶目标检测 船舶检测会遇到三个问题: 1.船低对比度 2.海平面情况复杂 3.云,礁等错误检测 实验步骤: 1.预处理海陆边界,掩膜陆地 2.异常检测获得感兴趣区域, ...

  7. D3.js的v5版本入门教程(第七章)—— 比例尺的使用

    D3.js的v5版本入门教程(第七章) 比例尺在D3.js中是一个很重要的东西,我们可以这样理解d3.js中的比例尺——一种映射关系,从domain映射到range域(为什么会是domain和rang ...

  8. 龙贝格积分(c++)

    用龙贝格算法计算积分 #include <iostream> #include<cmath> #include <iomanip> using namespace  ...

  9. Hadoop(三)—— YARN

    YARN产生的背景 Hadoop相关概念 Hadoop 1.0 由HDFS.MapReduce组成. Hadoop 2.0 克服1.0中HDFS和MapReduce存在的各种问题而提出的. YARN是 ...

  10. [Beta]第十次 Scrum Meeting

    [Beta]第十次 Scrum Meeting 写在前面 会议时间 会议时长 会议地点 2019/5/20 22:00 20min 大运村公寓6F寝室 附Github仓库:WEDO 例会照片 工作情况 ...