spring-boot - 如何通过 HTTPS 使用 springdoc-openapi-maven-plugin

标签 spring-boot maven openapi springdoc

我有一个 spring 项目,其中所有端点都运行 https,这会在尝试运行 mvn verify -Dspring.application.admin.enabled=true -Dspring-boot.run.profiles=dev< 时导致以下错误。有没有办法指定证书路径?或者使用 spring security 仅使用此端点 http 而不是 https 。

错误:

[ERROR] An error has occurred
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path 
building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find 
valid certification path to requested target

Pom.xml

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.3.0.RELEASE</version>
            <executions>
                <execution>
                    <id>pre-integration-test</id>
                    <goals>
                        <goal>start</goal>
                    </goals>
                </execution>
                <execution>
                    <id>post-integration-test</id>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <apiDocsUrl>https://localhost:8444/v3/api-docs</apiDocsUrl>
            </configuration>
        </plugin>

最佳答案

这与您本地的 SSL 配置有关。以下是一些提示:

  • 确保您已将证书导入到 JDK 信任库中。

  • JDK 信任库应该与您的 maven 使用的相同。

  • 在您的 CN 上,确保声明 localhost。

  • 当你运行maven命令时不要忘记添加:

    -Djavax.net.ssl.trustStore=/path/to/my-file.jks -Djavax.net.ssl.trustStorePassword=my-pass

关于spring-boot - 如何通过 HTTPS 使用 springdoc-openapi-maven-plugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63470321/

相关文章:

java - Spring AMQP 处理已删除的队列

android - 使用maven将android facebook sdk打包为apklib

scala - 告诉 Swagger 请求正文可以是单个对象或对象列表

maven - 使用 maven-assembly-plugin 构建 OSGi 包包括依赖项

maven - io.fabric8:docker-maven-plugin:0.15.3:build失败

spring-boot - 与 therapi-runtime-javadoc-scribe 和 lombok 冲突

Java OpenApi 生成器使用对象作为查询参数

java - Spring Boot 使用或不使用 Maven 运行?如果没有,JSP 就无法解析

java - 使用 Spring Boot 启动 tomcat 时出现 NotReadablePropertyException

java - Spring 启动+ quartz : "Requested bean is currently in creation: Is there an unresolvable circular reference?"