You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

点击Eureka服务链接跳转至登录页,无法查看ThreadPoolExecutorStatus信息

问题分析与解决方案

为什么会跳转到登录页?

  1. Spring Security自动配置触发基础认证:只要项目引入了spring-boot-starter-security依赖,Spring Boot会自动启用基础安全认证——哪怕你没自定义Security配置。Actuator端点默认会被这个自动配置保护,导致访问时触发登录跳转。
  2. Eureka跳转路径被误配置:如果你的Eureka实例配置中,status-page-url-path指向的不是/actuator/info,而是其他被Security保护的端点(比如/actuator/health),也会出现登录页。
  3. Actuator自身安全开关默认开启:Actuator默认启用了安全校验,即使你没自定义拦截规则,框架也会对端点做保护。

如何关闭该登录页(不使用全放行配置)

方案1:通过配置文件精准放行(无需编写代码)

在application.yml中添加以下配置,直接关闭Actuator的安全校验,或精准放行指定端点:

# 方式一:关闭Actuator整体安全校验
management:
  security:
    enabled: false
  endpoints:
    web:
      exposure:
        include: info # 确保info端点被暴露

# 方式二:仅放行/actuator/info,其他请求仍保持认证要求
spring:
  security:
    authorization:
      authorize-requests:
        request-matchers: "/actuator/info" -> permitAll()
        any-request -> authenticated()

方案2:使用新版Security配置类(替代废弃的WebSecurityConfigurerAdapter)

编写以下配置类,仅对/actuator/info放行,其他请求保留认证规则:

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
public class SecurityConfig {

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        http.csrf().disable()
                .authorizeHttpRequests(auth -> auth
                        .requestMatchers("/actuator/info").permitAll()
                        .anyRequest().authenticated()
                );
        return http.build();
    }
}

额外检查:确认Eureka实例配置

确保Eureka跳转的路径是已放行的端点,在application.yml中配置:

eureka:
  instance:
    status-page-url-path: /actuator/info

内容的提问来源于stack exchange,提问作者zijain zeng

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 20:42:54