spring cloud一开始好好的,后面因为升级为2.0以后。启动eureka没问题,但是启动client的时候一直报错:
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
网上搜索资料,很多都是说修改eureka配置:
eureka.client.register-with-eureka=false eureka.client.fetch-registry=false
但是这个代码是不将自己注册到eureka,但是现在是client注册不进去问题,所以认真查看原来之前项目eureka才发现少了点东西:
在eurekaApplication中新增代码:
@EnableWebSecurity
public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
super.configure(http);
}
}
完美解决问题,记录下来以后备用