如何在 Swagger UI 中公开 Actuator 端点?我希望我能翻转
show-actuator
旗帜
springdoc:
swagger-ui:
enabled: true
path: /swagger-ui
config-url: /swagger-ui/config
show-actuator: true
但是这样做会创建对启动的循环依赖(没有标志一切都很好)
ERROR 10972 --- [dynamic-gateway] [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The dependencies of some of the beans in the application context form a cycle:
org.springframework.security.config.annotation.web.reactive.ServerHttpSecurityConfiguration
┌─────┐
| org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration$EnableWebFluxConfiguration
↑ ↓
| swaggerWebFluxConfigurer defined in class path resource [org/springdoc/webflux/ui/SwaggerConfig.class]
↑ ↓
| actuatorProvider defined in class path resource [org/springdoc/webflux/core/configuration/SpringDocWebFluxConfiguration$SpringDocWebFluxActuatorConfiguration.class]
↑ ↓
| webEndpointReactiveHandlerMapping defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.class]
↑ ↓
| gatewayControllerEndpoint defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration$GatewayActuatorConfiguration.class]
↑ ↓
| modifyRequestBodyGatewayFilterFactory defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]
└─────┘
我的相关依赖:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- ... -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
错误消息指出与 Spring Cloud Gateway 和 Spring Security 的循环依赖。我构建了一个使用 webflux 与 springdoc 和执行器的小型应用程序,它工作得很好。
我认为还有一些其他配置在干扰您。 也许您可以提供有关您的安全性和网关配置的更多信息。
我已经在这里回答过类似的问题了。可能对你有帮助,请参考这个