解决:TransportException: Cannot execute request on any known server

今天在调试一个SpringCloud项目时,老是如下报错:

但无论如何,我还是解决了。

我从以下这两点着手:

第一:删除所有yml文件中的注释,包括链接或语句后看不到的空格

第二:手动关闭Spring2.0以后默认开启的安全验证

    /**
     * 允许Security跨域访问,否则客户端连接eureka会抛出异常
     * com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
     */
    @EnableWebSecurity
    static class WebSecurityConfig extends WebSecurityConfigurerAdapter {
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http.csrf().disable();
            super.configure(http);
        }
    }

然后我的项目就可以了。

猜你喜欢

转载自blog.csdn.net/lezeqe/article/details/109818300
今日推荐