Eureka註冊服務 Cannot execute request on any known serve

springboot版本是 Hoxton.SR3

Eureka服務添加security客戶端不能註冊的錯誤

服務端配置application.yml

server:
  port: 8000
spring:
  application:
    name: eureka-server
  security:
    user:
      name: user
      password: admin
eureka:
  instance:
    hostname: 127.0.0.1
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://127.0.0.1:8000/eureka/

在eureka服務端添加配置文件 去除csrf驗證

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.csrf ().disable ().authorizeRequests ().anyRequest ().authenticated ().and ().httpBasic ();
    }
}

在客戶端修改連接eureka地址

server:
  port: 8001
spring:
  application:
    name: client-server
eureka:
  instance:
    hostname: 127.0.0.1
  client:
    service-url:
       #user:admin是在eureka服務端設置的賬號密碼
      defaultZone: http://user:[email protected]:8000/eureka/

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章