为了账号安全,请及时绑定邮箱和手机立即绑定

在Docker中使用Spring Boot Actuator?

在Docker中使用Spring Boot Actuator?

宝慕林4294392 2021-04-06 17:14:28
我有一个带有自定义Spring Boot Acturators的Spring Boot微服务。当我直接运行Jar时,我可以访问所有的执行器,而当我在Docker-Image中运行相同的Jar时,会出现404错误。SecurityConfig:@Configurationpublic class ActuatorSecurityConfiguration extends WebSecurityConfigurerAdapter {    @Override    protected void configure(HttpSecurity http) throws Exception {        http                .requestMatcher(EndpointRequest.toAnyEndpoint())                .anonymous()                //.authorizeRequests()                //.anyRequest().authenticated()                .and()                .httpBasic();    }}Application.yaml:spring:    profiles: actuatormanagement.endpoints:    web.exposure.include: "*"    health.show-details: always这就像我的执行器的“样板代码”:@Component@RestControllerEndpoint(id = "acturatorName")public class acturatorNameActurator {    @GetMapping(value = "/foo", produces = "application/json")    public String bar(){        return "{\"status\":\"started\"}";    }    ...}当我仅运行Jar内部运行docker时,我的自定义执行器都无法工作吗?/actuator/info例如工作,但/actuator/metrics不。我该怎么做才能解决此问题?进阶输入
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 253 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信