平时自己开发的工具类或者其他的框架的jar包一般都是放在本地。或者把代码上传到github让别人去下载然后自己打包。今天就说说如何把自己的jar包发布到Maven的中央仓库。让其他使用你的jar包的直接去中央仓库下载。如果你用的是阿里云的maven中央仓库。同样阿里云的中央仓库也会同步你的jar包。
1 注册JIRA账号
注册地址:https://issues.sonatype.org/secure/Dashboard.jspa
2 创建 issue
这些都是要填写的!
Project URL 和SCM url 可以填写自己github项目的地址
Group ID 可以按自己需求填写,比如我填写的是com.ailikes
创建好以后 sonatype的工作人员审核处理,速度还是很快的,一般一个工作日以内,当Issue的Status变为RESOLVED后,就可以进行下一步操作了,否则,就等待
到了这里说明你已经能够去上传自己的jar包了
3 配置maven Setting.xml文件
添加Server节点
<server>
<id>自行替换</id>
<username>替换成自己的JIRA账号</username>
<password>替换成自己的JIRA账号密码</password>
</server>
4 创建maven工程
设置pom.xml文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ailikes</groupId>
<artifactId>common-util</artifactId>
<version>1.1.0-RELEASE</version>
<name>common-util</name>
<packaging>jar</packaging>
<description>工具类工程</description>
<url>https://github.com/AilikesXu/common-util.git</url>
<developers>
<developer>
<name>ailikes</name>
<id>ailikes</id>
<email>15600499930@163.com</email>
<roles>
<role>Developer</role>
</roles>
<timezone>+8</timezone>
</developer>
</developers>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<scm>
<url>https://github.com/AilikesXu</url>
<connection>https://github.com/AilikesXu/common-util.git</connection>
</scm>
<properties>
<argLine>-Dfile.encoding=UTF-8</argLine>
<project-description>工具类工程</project-description>
<java-version>1.7</java-version>
<org.aspectj-version>1.8.4</org.aspectj-version>
<org.slf4j-version>1.7.9</org.slf4j-version>
<!-- 不加下面这一行会报错 [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! 增加之后 Using 'UTF-8' encoding to copy filtered resources. -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.springframework-version>4.1.4.RELEASE</org.springframework-version>
<jetty.version>8.1.16.v20140903</jetty.version>
</properties>
<dependencies>
<!-- java bean 验证 -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.1.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<!-- 指定source和target的jdk版本是1.7 -->
<source>1.7</source>
<target>1.7</target>
</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</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release</id> <!-- 部署要用到 -->
<build>
<plugins>
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GPG -->
<plugin> <!-- 进行验签 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</profile>
</profiles>
</project>
必须要的:name url description licenses scm <distributionManagement>
<snapshotRepository> <id>oss</id><!-- settings.xml中server节点的id--> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> </snapshotRepository> <repository> <id>oss</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> </distributionManagement>
5 windows环境安装gpg4win
下载地址:https://www.gpg4win.org/download.html
查看版本:
$ gpg --gen-key
gpg (GnuPG) 1.4.19; Copyright (C) 2015 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection?
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) Y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
Real name: ljbmxsm
Email address: ljbmxsm@gmail.com
Comment: flink-elasticsearch-connector
You selected this USER-ID:
"iteblog (flink-elasticsearch-connector) <wyphao.2007@163.com>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
+++++
.+++++
gpg: /c/Users/iteblog/.gnupg/trustdb.gpg: trustdb created
gpg: key B15C5AA3 marked as ultimately trusted
public and secret key created and signed.
设置名字+邮箱,其他可以使用默认值,记住输入的passphrase,部署会用到
6 上传密钥
上传刚刚生成的秘钥
上传命令
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys CF21873A--上传到服务器
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --recv-keys CF21873A --查看是否上传整个
- 1
- 2
主要:keyserver.ubuntu.com:11371 现在这个是可用的,之前网上的pool.sks-keyservers.net 反正我上传成功但是在后面验证的时候不是用的这个地址。
7执行部署
mvn clean deploy -P release
- 1
后面的release参数是 <id>release</id> <!-- 部署要用到 -->
这个
8 登录网站查看
地址:https://oss.sonatype.org
用户名密码就是上面注册的。
查看自己的(你定义的版本号不能带SNAPSHOT要不然看不到)
a)构件准备好之后,在命令行上传构建;
b)在https://oss.sonatype.org/ “close”并“release”构件;
c)等待同步好(大约2小时多)之后,就可以使用了
9 通知管理员
去网站https://issues.sonatype.org 登录通知你的管理然后等待
然后到这里就全部完成。剩下的就是等同步到中央仓库
看看我自己随便发布的一个结果:
去中央仓库查看https://search.maven.org(中央仓库需要两个小时后)
相关推荐
比如sqljdbc.jar在Maven中央仓库中找不到,但是我们的maven工程中确实需要这样的一个jar包,那么我们首先需要下载对应版本的sqljdbc.jar包到本地,然后按照以下的命令添加到本地仓库。(ps:前提是你已经下载并配置...
比较常用的Jar包,maven比较常用的Jar包不用从中央仓库下载。节省时间
一键删除maven本地仓库中下载错误的jar包资源(以lastUpdated结尾的文档)
JarsCrawler 爬取阿里maven中央仓库的所有jar包
将jar包依赖关系拷贝到pom.xml文件中的dependencies标签体中; 运行bat文件即可 具体操作:http://www.cnblogs.com/Marydon20170307/p/9149256.html
maven的本地仓库jar包,方便那些不能上远程仓库下载的朋友们,这个就是我从中央仓库下载下来的资源,如果有需要的可以下载
https://mvnrepository.com/ 输入想要的jar包,点击 search 点击版本号,复制maven pom.xml,点击View All,下载jar包到本地 cmd 命令,安装jar包到本地仓库
Maven中央仓库缺少项目使用的Jar包,通常有两种处理方法: 一、在自己的Maven私服中上传对应的Jar包 二、没有Maven私服的情况,可以下载对应的Jar包放置在本地的仓库
致力研发国产IOC框架,主打轻、简、快特征,已登录Maven中央仓库
当maven项目中从中央仓库中找到不到某些Jar包,或者想把自己开发的Jar文件引入到项目中...可以把Jar包上传maven中央仓库或自建的私服,但有时候上述条件不好满足或操作麻烦,可直接在本地配置Maven的POM文件就可以了。
主要介绍了详解如何将JAR包发布到Maven中央仓库,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
主要介绍了如何把JAR发布到maven中央仓库的几种方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
有时在你的构建过程中,需要将第三方jar包添加到本地仓库中,因为它并存在于像Maven中央仓库或其它的公共仓库中。为了让Maven能够正确获取到jar包,第三方jar包必须放置到本地仓库的正确位置上。Maven已经提供了...
qrcode所需要的依赖jar包,maven中央仓库是没有的。
进行maven项目开发时,经常会遇到某些jar包无法从中央仓库中下载下来的问题,pom.xml中报missing artifact的错误,遇到这种情况时,可先将无法下载的jar包通过其它途径下载到本地,以本文为例,将所有无法从中央仓库...
kettle是国外开源的一款ETL集成工具,其最新版8.2版本改为了maven项目,由于其maven仓库下载实在太慢,这里提供了我费了一两天才下载好的依赖包,直接解压放在本地仓库即可。方便好使,好用的给个五星好评。
maven本地仓库的jar是怎样下载的,maven项目中的jar引用过程,本地仓库,中央仓库,远程仓库的区别理解,镜像配置的理解,标签的作用.
中央仓库maven的下载,让你减少自己找jar包的痛苦,提高代码的效率