视频播放地址

优酷播放地址

参考文档

遇到的问题

  • maven set.xml pom.xml特殊字符报错 Unescaped & or nonterminated character/entity reference
  <server>
    <id>oss</id>
    <username>wangji</username>
    <password><![CDATA[]]></password>
  </server>

处理步骤

1、注册中央仓库的地址

说到中央仓库,不得不说 Sonatype 这家公司,因为中央仓库就是这家公司砸钱搞的,并且免费向全球所有的 Java 开发者提供构件托管服务,这对于我们而言,简直就是“福利”啊!
地址:https://issues.sonatype.org/login.jsp
这里的用户名与密码是非常重要的,后面会用到,一定要保存好。

此外,Sonatype 还提供了一个名为 OSS 的系统:
地址: Sonatype OSS:https://oss.sonatype.org

2、创建一个 Issue

  • 最重要的就是groupId的地址信息

[外链图片转存失败(img-VTrlOOaH-1567233633011)(https://cdn.nlark.com/yuque/0/2018/png/171220/1543740506219-1b0496ce-3732-4c49-a038-99a0792b3678.png “”)]

上面最主要的就是groupId的信息,其他的都不是非常的重要!

3、等待审批通过

他会回复你的,成功了之后就可以开始发布了

[外链图片转存失败(img-d0KlKkiB-1567233633012)(https://cdn.nlark.com/yuque/0/2018/gif/171220/1543740727192-ec5517c4-0290-4f59-80a7-cd77b66393c2.gif “”)]

4、使用 GPG 生成密钥对

brew install gpg
gpg --gen-key
--根据提示输入信息

--查询生成的公钥的信息
$ gpg --list-keys
/Users/wangji/.gnupg/pubring.kbx
--------------------------------
pub   rsa2048 2018-12-02 [SC] [有效至:2020-12-01]
      DE23BD78E68EDE1C2A1A修改成为自己的
uid           [ 绝对 ] wangji <983433479@qq.com>
sub   rsa2048 2018-12-02 [E] [有效至:2020-12-01]

--上传到密钥服务器
$ gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys DE23BD78E68E修改成自己的
gpg: 将密钥‘35A70B50563D4C8B’上传到 hkp://keyserver.ubuntu.com:11371

--查询密钥是否上传成功
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --recv-keys DE23BD78E68E修改成自己的
gpg: 密钥 35A70B50563D4C8B:“wangji <983433479@qq.com>”未改变
gpg: 合计被处理的数量:1
gpg:           未改变:1
  • mac 部署失败
$ mvn clean deploy -P release -Darguments=gpg.passphrase="密钥密码"

INFO] — maven-gpg-plugin:1.6:sign (oss) @ spirng-parameter-validator —
gpg: 签名时失败: Inappropriate ioctl for device
gpg: signing failed: Inappropriate ioctl for device

这说明你安装的gpg版本较新,需要额外配置,在gpg安装目录(mac的是~/.gnup)下建立两个配置文件:gpg.conf、gpg-agent.conf,

然后在gpg.conf添加:

use-agent
pinentry-mode loopback

在gpg-agent.conf下添加:

allow-loopback-pinentry

保存后再次执行上面的deploy命令,如果还有报错,通常情况下是你上面maven配置出了问题,检查maven配置是否有语法错误,配置的账号和密码等有无需要转义的特殊字符。还需要注意的是生成密钥和执行部署命令的必须是同一台机器。

配置文件:
download: gpg配置文件.zip

5、修改 Maven 配置文件

setting中配置 Sonatype中注册的用户名和密码

[外链图片转存失败(img-t0WI5BtK-1567233633012)(https://cdn.nlark.com/yuque/0/2018/png/171220/1543741991874-8d77fafe-03d9-4266-b552-453b8f5ec608.png “”)]

  <server>
    <id>oss</id>
    <username>wangji</username>
    <password><![CDATA[密码]]></password>
  </server>

pom.xml中配置,参考了https://github.com/looly/hutool/blob/v4-master/pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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.github.WangJi92</groupId>
    <artifactId>spirng-parameter-validator</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <properties>
        <spring.version>4.3.18.RELEASE</spring.version>
    </properties>
    <name>spirng-parameter-validator</name>
    <description>Encapsulated Hibernate Validator for easy use in spring!Use spring aop with hibernate validator!</description>
    <url>https://github.com/WangJi92/Hibernate-validator-in-spring</url>

    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>7</version>
    </parent>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <url> https://github.com/WangJi92/Hibernate-validator-in-spring</url>
        <connection>https://github.com/WangJi92/Hibernate-validator-in-spring.git</connection>
        <developerConnection>https://github.com/WangJi92/Hibernate-validator-in-spring</developerConnection>
    </scm>
    <developers>
        <developer>
            <name>wangji</name>
            <email> 983433479@qq.com</email>
            <url>https://github.com/WangJi92/Hibernate-validator-in-spring</url>
        </developer>
    </developers>
    <build>
        <finalName>hibernate-validator-spring</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <attach>true</attach>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

        </plugins>

    </build>
    <profiles>
        <profile>
            <id>release</id>
            <distributionManagement>
                <snapshotRepository>
                    <id>oss</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>
            <build>
                <plugins>
                    <!-- Source -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>oss</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Gpg Signature -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>oss</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.8</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>oss</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

这里很详细: 将 Smart 构件发布到 Maven 中央仓库

6、发布到OSS

这一步主要是生成相应的一些jar包和签名文件,并上传到OSS的服务器,命令也比较简单

 mvn clean deploy -P release -Darguments=gpg.passphrase="密钥密码"

这一步特别说明下,按照原博主的说法,执行mvn clean deploy -P release会自动弹出一个对话框,我这里没有弹出来……而且报签名异常,后来百度之,得加上-Dgpg.passphrase=你的Passphase这个参数,用你自己的Passphase,就可以成功了,还有-P参数表示使用的profile名,就是profile下release这个标签的内容。
maven-gpg-plugin

7、添加一个回复

Component has been successfully issued

[外链图片转存失败(img-4UVrBys0-1567233633013)(https://cdn.nlark.com/yuque/0/2018/png/171220/1543742673415-d1485d4e-6a79-49be-8954-eadaa6524b27.png “”)]

https://oss.sonatype.org/#nexus-search;quick~com.github.WangJi92 这个OSS里面我什么都没有操作就OK啦!我也搞不懂为什么?

8、 然后就是等待了

阿里云搜索: http://maven.aliyun.com/mvn/search

[外链图片转存失败(img-uCq5Y8Kj-1567233633013)(https://cdn.nlark.com/yuque/0/2018/png/171220/1543742731275-c416521d-25ec-4c00-a0c9-199ad7b1761e.png “”)]
中央仓库搜索网站:https://search.maven.org/search?q=g:com.github.WangJi92

[外链图片转存失败(img-lrLathPo-1567233633013)(https://cdn.nlark.com/yuque/0/2018/png/171220/1543742974490-44b35b89-0db7-4b46-b32b-f2459b64d6cf.png “”)]