slash-doc
Used in:
components
- OverviewOverview
- VersionsVersions
- DependentsDependents
- DependenciesDependencies
<dependency>
<groupId>site.lanmushan</groupId>
<artifactId>slash-doc</artifactId>
<version>2026.01.07.01</version>
</dependency><?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- 注意:不再使用 oss-parent,因为新的 Central Publishing 不需要它 -->
<!-- oss-parent 是旧的 OSS 发布方式,会与 central-publishing-maven-plugin 冲突 -->
<!-- 如果需要 parent,可以使用 spring-boot-starter-parent,但这里不需要 -->
<groupId>site.lanmushan</groupId>
<artifactId>slash-doc</artifactId>
<version>2026.01.07.01</version>
<packaging>pom</packaging>
<name>slash-doc</name>
<description>SpringDoc OpenAPI 增强库,支持 Springfox 注解兼容和 JSR-303/380 验证注解增强</description>
<url>https://gitee.com/lanmushan/slash-doc</url>
<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>
<developers>
<developer>
<name>daiyu</name>
<email>lanmu_shan@163.com</email>
<organization>CloudNil</organization>
</developer>
</developers>
<scm>
<tag>master</tag>
<url>https://gitee.com/lanmushan/slash-doc.git</url>
<connection>https://gitee.com/lanmushan/slash-doc.git</connection>
</scm>
<properties>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<spring-boot.version>3.5.3</spring-boot.version>
<maven.compiler-plugin.version>3.11.0</maven.compiler-plugin.version>
<maven.source.plugin.version>3.3.0</maven.source.plugin.version>
<maven.javadoc.plugin.version>3.6.3</maven.javadoc.plugin.version>
<maven.enforcer.plugin.version>3.4.1</maven.enforcer.plugin.version>
<maven.clean.plugin.version>3.4.0</maven.clean.plugin.version>
<maven.install.plugin.version>3.1.3</maven.install.plugin.version>
<maven.surefire.plugin.version>3.5.2</maven.surefire.plugin.version>
<maven.jar.plugin.version>3.4.2</maven.jar.plugin.version>
<!-- GPG 配置:默认启用签名,可通过 -Dgpg.skip=true 禁用 -->
<!-- GPG 密码和密钥名称从 settings.xml 的 profile 中读取 -->
<gpg.skip>false</gpg.skip>
</properties>
<modules>
<module>slash-doc-demo</module>
<module>slash-doc-starter</module>
</modules>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<type>pom</type>
<scope>import</scope>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>site.lanmushan</groupId>
<artifactId>slash-doc-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>site.lanmushan</groupId>
<artifactId>slash-doc-demo</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<!-- Maven Enforcer 插件:确保 Maven 和 Java 版本符合要求 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven.enforcer.plugin.version}</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.6.0</version>
</requireMavenVersion>
<requireJavaVersion>
<version>17</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.javadoc.plugin.version}</version>
<configuration>
<!-- 启用 JavaDoc 生成,Central Publishing 要求必须有 JavaDoc -->
<skip>false</skip>
<encoding>UTF-8</encoding>
<charset>UTF-8</charset>
<docencoding>UTF-8</docencoding>
<!-- 忽略缺少注释的警告 -->
<additionalOptions>
<additionalOption>-Xdoclint:none</additionalOption>
</additionalOptions>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Central Publishing Maven Plugin:新的 Maven Central 发布方式 -->
<!-- 注意:此插件会自动绑定到 deploy phase,无需手动配置 execution -->
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.9.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
</configuration>
</plugin>
<!-- 跳过 maven-deploy-plugin 的默认 deploy,让 central-publishing-maven-plugin 完全接管 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<!-- 在 deploy 之前清理 .locks 文件(central-publishing-maven-plugin 会生成这些文件) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>clean-locks</id>
<phase>pre-deploy</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- 清理所有模块的 target 目录中的 .locks 文件 -->
<delete>
<fileset dir="${project.basedir}" includes="**/*.locks" />
</delete>
<!-- 清理 central-staging 目录中的 .locks 文件 -->
<delete>
<fileset dir="${project.build.directory}/central-staging" includes="**/*.locks" />
</delete>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven.source.plugin.version}</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version> <!-- 升级到最新稳定版 -->
<configuration>
<!-- Central Publishing 要求所有文件必须有 GPG 签名 -->
<!-- 默认启用,可通过 -Dgpg.skip=true 禁用 -->
<skip>${gpg.skip}</skip>
<keyname>${gpg.keyname}</keyname>
<passphrase>${gpg.passphrase}</passphrase>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>package</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler-plugin.version}</version>
<configuration>
<source>17</source>
<target>17</target>
<release>17</release>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- Maven Enforcer 插件版本管理 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven.enforcer.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven.clean.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${maven.install.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven.jar.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<distributionManagement>
<!-- Central Publishing 会自动处理发布,但需要保留此配置以匹配 settings.xml 中的服务器 ID -->
<repository>
<id>central</id>
<name>Central Publishing</name>
<url>https://central.sonatype.com/</url>
</repository>
<snapshotRepository>
<id>central</id>
<name>Central Publishing</name>
<url>https://central.sonatype.com/</url>
</snapshotRepository>
</distributionManagement>
<!--
============================================
Central Publishing 部署命令(正确方式):
============================================
命令(重要:必须使用 deploy,不能使用 install):
mvnd clean deploy -DskipTests
或者
mvn clean deploy -DskipTests
注意:
- deploy:部署到远程仓库(Central Publishing),会触发 central-publishing-maven-plugin
- install:仅安装到本地仓库,不会上传到远程仓库
- 如果只运行 install,不会触发 Central Publishing,文件不会上传到 Maven Central
重要提示:
1. 不要使用 -P sonatype-oss-release profile(这是旧的 OSS 发布方式)
2. 不要使用 -Dmaven.javadoc.skip=true(Central Publishing 要求必须有 JavaDoc)
3. central-publishing-maven-plugin 会自动执行,无需特殊 profile
4. 确保 settings.xml 中配置了正确的服务器认证信息(id=central)
5. 确保 settings.xml 中配置了 GPG keyname 和 passphrase
GPG 签名要求:
- Central Publishing 要求所有文件必须有 GPG 签名
- 如果遇到 "Cannot run program gpg.exe" 错误,需要:
1. 安装 GnuPG:https://www.gnupg.org/download/
2. 将 GPG 安装目录添加到系统 PATH 环境变量
3. 或者使用 -Dgpg.skip=true 临时跳过(仅用于测试,最终部署必须签名)
settings.xml 配置要求(E:\apache-maven-3.6.0-bin\apache-maven-3.6.0\conf\settings.xml):
1. 必须配置 server id=central(Central Publishing 必需):
<servers>
<server>
<id>central</id>
<username>您的Sonatype用户名</username>
<password>您的SonatypeUserToken</password>
</server>
</servers>
2. 必须配置 profile 提供 GPG 信息:
<profiles>
<profile>
<id>sonatype-oss-release</id>
<properties>
<gpg.keyname>您的GPG密钥ID</gpg.keyname>
<gpg.passphrase>您的GPG密钥密码</gpg.passphrase>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>sonatype-oss-release</activeProfile>
</activeProfiles>
3. 确保没有重复的 server id(特别是 sonatype-oss-release)
4. 获取 User Token:
- 登录 https://central.sonatype.com/
- 进入 User Token 页面
- 生成新的 User Token(如果还没有)
- 将 Token 配置到 settings.xml 的 server id=central 的 password 中
部署验证和问题排查:
1. 检查部署日志:
- 部署成功会看到 "BUILD SUCCESS"
- 查看日志中是否有 "central-publishing" 相关的信息
- 查看是否有 "Deployment" 相关的成功消息
2. 检查 Central Publishing 状态:
- 登录 https://central.sonatype.com/
- 进入 "My Activities" 或 "Publishing" 页面
- 查看是否有正在处理或已完成的发布任务
- 如果看到 "In Progress" 状态,需要等待处理完成(通常几分钟到几小时)
3. 常见问题:
- 如果部署命令执行成功但没有看到上传,检查:
a) settings.xml 中的 server id=central 配置是否正确
b) User Token 是否有效(可能已过期)
c) 网络连接是否正常
- 如果看到 "Deployment failed" 错误,检查:
a) GPG 签名是否正确
b) 所有必需的文件(sources, javadocs)是否都已生成
c) 项目元数据(licenses, developers, scm)是否完整
4. 发布到 Maven Central 的时间:
- 部署成功后,Central Publishing 会自动处理发布
- 通常需要几分钟到几小时才能同步到 Maven Central
- 可以在 https://central.sonatype.com/ 查看发布状态
- 发布成功后,可以在 https://repo1.maven.org/maven2/ 搜索您的 artifact
-->
</project>