发布jar包到maven中央仓库之pom文件

>> 饿了么、美团外卖红包领取地址<<

完整过程参考:发布jar包到maven中央仓库教程

发布jar包到maven中央仓库需要对本地maven的配置文件进行修改,我们需要在节点下增加以下内容

<server>
    <id>sonatype</id>
    <username>liqingcan</username>
    <password>youpassword</password>
</server>

其中username和password分别是你注册sonatype时的账号名和密码。https://issues.sonatype.org/secure/Dashboard.jspa

完整的项目pom文件的结构如下方样例,建议直接复制过来进行修改。

<?xml version="1.0"?>
<project
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
        xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.github.lqccan</groupId>
    <artifactId>wechat-work-bot</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <url>https://github.com/lqccan/wechat-work-bot</url>

    <name>wechat-work-bot</name>
    <description>a sdk for wechat work bot</description>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>
    <developers>
        <developer>
            <name>liqingcan</name>
            <email>1102946234@qq.com</email>
        </developer>
    </developers>
    <scm>
        <connection>https://github.com/lqccan/wechat-work-bot</connection>
        <developerConnection>https://github.com/lqccan/wechat-work-bot</developerConnection>
        <url>https://github.com/lqccan/wechat-work-bot</url>
    </scm>

    <properties>
        <java.version>1.8</java.version>
        <javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <!--阿里巴巴的json包-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.62</version>
        </dependency>
        <!--hutool工具包-->
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>4.1.12</version>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <!-- 这个id就是打包时的 -P 参数 -->
            <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>
                                <!-- -Xdoclint:none 是为了避免生成apidoc的时候检查过于严格而报错-->
                                <configuration>
                                    <additionalparam>-Xdoclint:none</additionalparam>
                                </configuration>
                            </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>
            <!-- snapshotRepository与repository的id应与setting.xml中添加的server的id一致 -->
            <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>

觉得内容还不错?打赏个钢镚鼓励鼓励!!👍

彩虹烘鞋器可伸缩快速干鞋机家用旅行便携式烤鞋暖鞋器成人儿童安全烘干器鞋靴除湿机 伸缩款Q8103
¥46.00
成人本科学士学位英语统一考试星级词汇大冲关(第2版 乱序版)
¥18.09
卫龙魔芋爽600g香辣素毛肚休闲零食大礼包情人节送女友生日礼物辣条
¥35.90
励展(LIZHAN)医用外科口罩一次性成人防护三层医疗正品透气轻薄防尘50只/盒 蓝色非独立
¥19.80
清濮上品 四川春见耙耙柑 4.5-5斤75-85mm 新鲜柑橘水果丑橘子 年货送礼
¥38.90
内廷上用灰甲灵冷敷凝胶足部肿胀疼痛灰指甲足痒足癣足臭甲癣
¥49.80
瓦力【抗蓝光】荣耀80pro钢化膜荣耀80pro手机膜 曲面防摔耐磨保护手机贴膜
¥41.80
手护佳 一次性食品级丁腈手套 厨房家用公司复工学生开学劳保防护 盒装100只蓝色 L号
¥47.30