eureka 配置了 security 认证后,服务注册的时候“无法执行请求”
需要在服务中加上以下配置类(如果配置文件没问题的情况,这种方式直接解决)
@EnableWebSecurity
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable(); //关闭csrf
http.authorizeRequests().anyRequest().authenticated().and().httpBasic(); //开启认证
}
}