Spring Boot Actuator监控页面报错解决

时间:2022-05-06
本文章向大家介绍Spring Boot Actuator监控页面报错解决,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

今天在访问Spring Boot Actuator监控页面的时候报错了,之前都没遇到这种情况,大概的意思就是无权限访问

<html>
  <body>
   <h1>Whitelabel Error Page</h1>
   <p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p>
   <div id='created'>Tue Nov 07 14:14:32 CST 2017</div>
   <div>There was an unexpected error (type=Unauthorized, status=401).</div>
   <div>Full authentication is required to access this resource.</div>
  </body>
</html>

然后我看了下控制台,找到了有用的信息

说访问端点信息需要认证身份,请将management.security.enabled设置为false来关闭验证功能

2017-11-07 14:13:19.742  INFO 11232 --- [nio-2101-exec-1] s.b.a.e.m.MvcEndpointSecurityInterceptor : Full authentication is required to access actuator endpoints. Consider adding Spring Security or set 'management.security.enabled' to false.

解决方案当然就是在属性文件中加上management.security.enabled=false

那么为什么会出现这种情况呢,我看了下源码,之前我用的spring boot是1.4.2版本的,源码里面是没有MvcEndpointSecurityInterceptor 这个拦截器的

目前用的spring boot是1.5.4,应该是新版本加进来的,这就是为什么之前没有遇到过这个问题

关于actuator的使用可以查询我的这篇文章:http://cxytiandi.com/blog/detail/8123