![](/img/trans.png)
[英]How to expose Spring's HttpSecurity Logout endpoint in swagger-ui if using springdoc-openapi library?
[英]404 error on Swagger UI with Spring (springdoc-openapi configuration)
我正在將 swagger UI 添加到我的 Spring boot 應用程序中。 當我嘗試訪問 swagger-ui.html 時。 我收到 404 錯誤。
配置類:
@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI springShopOpenAPI() {
return new OpenAPI()
.info(new Info().title("JOYAS-STOCK API Docs")
.description("JOYAS-STOCK REST API documentation")
.version("v1.0.0"));
}
}
應用程序.properties:
#swagger-ui config
springdoc.swagger-ui.path=/swagger-ui
springdoc.swagger-ui.operationsSorter=method
springdoc.swagger-ui.tagsSorter=alpha
pom.xml:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.13</version>
</dependency>
錯誤消息:Whitelabel Error Page 此應用程序沒有針對 /error 的顯式映射,因此您將其視為后備。
出現意外錯誤(類型=未找到,狀態=404)。
我從實施 swagger 配置開始,顯然它沒有用。
解決。
問題出在版本上,它們不兼容。 我在 spring boot 3 中使用 springdoc-openapi v1,這是錯誤的。 使用 spring boot 3:應該使用 springdoc-openapi v2。 請參閱文檔: https ://springdoc.org/v2/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.