Spring Boot /swagger-ui.html不工作,它显示404错误

chhkpiq4  于 2022-12-13  发布在  Spring
关注(0)|答案(1)|浏览(167)

为Sping Boot 应用程序配置openapi 3时,“/swagger-ui.html”端点不工作,它显示404错误。以下是pom.xml文件。

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
            <version>2.0.0-M4</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
        </dependency>

    </dependencies>
ktca8awb

ktca8awb1#

我在enable swagger ui(openapi 3)规范中使用了这个依赖项,更多细节请参考这个链接

<dependency>
  <groupId>org.springdoc</groupId>
  <artifactId>springdoc-openapi-ui</artifactId>
  <version>1.6.13</version>
</dependency>

我希望它能在没有这种依赖关系的情况下工作

<dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
        <version>2.0.0-M4</version>
</dependency>

而swagger用户界面链接将如下所示:
在文档中,格式为http://server:port/context-path/swagger-ui.html通过此链接了解有关上下文路径的详细信息

相关问题