首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >多模块SpringBoot应用程序中不可用的致动器端点

多模块SpringBoot应用程序中不可用的致动器端点
EN

Stack Overflow用户
提问于 2022-10-09 16:24:19
回答 1查看 103关注 0票数 1

我有一个多模块的SpringBoot应用程序,它有以下模块:

  • 域名
  • 服务
  • 坚持性
  • api接口
  • 应用程序

在"api“层,我维护所有控制器和dtos,在应用程序中,我将依赖项添加到模块中,然后构建我的SpringBoot (Version2.6.6)应用程序。我正在尝试添加,其中包含一个自定义的信息端点,该端点还显示应用程序版本,并查看OpenAPI仪表板中的所有端点。由于某些原因,我不能让它工作,我只是得到403个与执行器相关的一切,我没有看到端点在OpenAPI (V3)。

我的情况如下:

  • 在“应用程序”中,我有一个依赖项:
代码语言:javascript
运行
复制
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

application.properties:

代码语言:javascript
运行
复制
management.security.enabled = false
springdoc.show-actuator=true

我还在安全配置中添加了这些行(可能是api前缀以某种方式介入)。

代码语言:javascript
运行
复制
.antMatchers(apiPrefix + "/actuator/**").permitAll() //I have a API prefix for all backend calls
.antMatchers("/actuator/**").permitAll()

在“应用程序”中,我也定义了spring maven-plugin:

代码语言:javascript
运行
复制
<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>build-info</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

我该如何修正我的代码?

EN

回答 1

Stack Overflow用户

发布于 2022-10-09 21:15:31

目前还不清楚您使用的Spring版本是什么版本。从2.0开始,您必须启用并公开与执行器相关的端点。

下面应该告诉您应用程序当前可用的是什么:

代码语言:javascript
运行
复制
GET http://<host>:<port>/actuator

例如,下面的application.yaml片段应该启用并只公开信息和健康终结点:

代码语言:javascript
运行
复制
management:
  endpoints:
    enabled-by-default: false
    web:
      exposure:
        include:
          - info
          - health
  endpoint:
    health:
      enabled: true
    info:
      enabled: true

Spring 参考文献应该会给出更多的细节。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74006479

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档