我有一个多模块的SpringBoot应用程序,它有以下模块:
在"api“层,我维护所有控制器和dtos,在应用程序中,我将依赖项添加到模块中,然后构建我的SpringBoot (Version2.6.6)应用程序。我正在尝试添加,其中包含一个自定义的信息端点,该端点还显示应用程序版本,并查看OpenAPI仪表板中的所有端点。由于某些原因,我不能让它工作,我只是得到403个与执行器相关的一切,我没有看到端点在OpenAPI (V3)。
我的情况如下:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>application.properties:
management.security.enabled = false
springdoc.show-actuator=true我还在安全配置中添加了这些行(可能是api前缀以某种方式介入)。
.antMatchers(apiPrefix + "/actuator/**").permitAll() //I have a API prefix for all backend calls
.antMatchers("/actuator/**").permitAll()在“应用程序”中,我也定义了spring maven-plugin:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>我该如何修正我的代码?
发布于 2022-10-09 21:15:31
目前还不清楚您使用的Spring版本是什么版本。从2.0开始,您必须启用并公开与执行器相关的端点。
下面应该告诉您应用程序当前可用的是什么:
GET http://<host>:<port>/actuator例如,下面的application.yaml片段应该启用并只公开信息和健康终结点:
management:
endpoints:
enabled-by-default: false
web:
exposure:
include:
- info
- health
endpoint:
health:
enabled: true
info:
enabled: trueSpring 参考文献应该会给出更多的细节。
https://stackoverflow.com/questions/74006479
复制相似问题