spring eureka security 批量更新失败,HTTP 状态码为 401

Ker*_* Hu 8 spring spring-security spring-cloud netflix-eureka spring-cloud-netflix

我研究 spring cloud eureka,cloud 并且它们工作得很好。但是在eureka服务中添加了安全性后,却遇到了一些错误。

所有代码和错误细节都在https://github.com/keryhu/eureka-security

eureka 服务 application.yml

security:
  user:
    name: user
    password: password

eureka: 
  client:
    registerWithEureka: false
    fetchRegistry: false
  server:
    wait-time-in-ms-when-sync-empty: 0 
Run Code Online (Sandbox Code Playgroud)

和 config-service application.java

@SpringBootApplication
@EnableConfigServer
@EnableDiscoveryClient
Run Code Online (Sandbox Code Playgroud)

配置服务应用程序.yml

eureka:
  client:
    registry-fetch-interval-seconds: 5
    serviceUrl:
       defaultZone: http://user:password@${domain.name:localhost}:8761/eureka/

spring:  
  cloud:
     config:
       server:
         git:
           uri: https://github.com/spring-cloud-samples/config-repo
           basedir: target/config 
Run Code Online (Sandbox Code Playgroud)

启动config-service后有错误导出:

2016-04-10 11:22:39.402 ERROR 80526 --- [get_localhost-3] c.n.e.cluster.ReplicationTaskProcessor   : Batch update failure with HTTP status code 401; discarding 1 replication tasks
2016-04-10 11:22:39.402  WARN 80526 --- [get_localhost-3] c.n.eureka.util.batcher.TaskExecutors    : Discarding 1 tasks of TaskBatchingWorker-target_localhost-3 due to permanent error
2016-04-10 11:23:09.411 ERROR 80526 --- [get_localhost-3] c.n.e.cluster.ReplicationTaskProcessor   : Batch update failure with HTTP status code 401; discarding 1 replication tasks
2016-04-10 11:23:09.412  WARN 80526 --- [get_localhost-3] c.n.eureka.util.batcher.TaskExecutors    : Discarding 1 tasks of TaskBatchingWorker-target_localhost-3 due to permanent error
2016-04-10 11:23:39.429 ERROR 80526 --- [get_localhost-3] c.n.e.cluster.ReplicationTaskProcessor   : Batch update failure with HTTP status code 401; discarding 1 replication tasks
2016-04-10 11:23:39.430  WARN 80526 --- [get_localhost-3] c.n.eureka.util.batcher.TaskExecutors    : Discarding 1 tasks of TaskBatchingWorker-target_localhost-3 due to permanent error
Run Code Online (Sandbox Code Playgroud)

小智 7

SET eureka.client.serviceUrl.defaultZone of eureka-server http://username:password@localhost:8761/eureka/