原因:spring security在引入actuator后安全校验配置.不配置其他接口就会报401
@EnableWebSecurity
@Configuration(proxyBeanMethods = false)
public class ActuatorSecurityConfiguration extends WebSecurityConfigurerAdapter {
/**
* http验证配置.
*
* @param http
* @throws Exception
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
http.requestMatcher(EndpointRequest.toAnyEndpoint())
// 放开所有验证
.authorizeRequests((requests) -> requests.anyRequest().permitAll());
}
}