【问题标题】:spring eureka security Batch update failure with HTTP status code 401spring eureka security 批量更新失败,HTTP 状态码为 401
【发布时间】:2016-07-31 05:46:44
【问题描述】:

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

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

eureka 服务应用程序.yml

security:
  user:
    name: user
    password: password

eureka: 
  client:
    registerWithEureka: false
    fetchRegistry: false
  server:
    wait-time-in-ms-when-sync-empty: 0 

还有配置服务application.java

@SpringBootApplication
@EnableConfigServer
@EnableDiscoveryClient

配置服务应用程序.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 

启动配置服务后导出错误:

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

【问题讨论】:

  • 你可以试试 Brixton.RC2 吗?
  • @spencergibb 我使用 Brixton.RC1
  • 是的,请用RC2试试,如果还有问题,我们可以看看。
  • @spencergibb ,我已经更新到 RC2,但 eureka 仍然有 Batch update failure with HTTP status code 401; discarding 1 replication tasks...
  • 你的eureka服务也需要设置安全serviceUrl

标签: spring spring-security spring-cloud netflix-eureka spring-cloud-netflix


【解决方案1】:

我同意jacky-fan 的回答。

这些是我的工作配置在没有用户名和密码的情况下的样子。

服务器应用程序.yml

spring:
  application:
    name: eureka-service
server:
  port: 8302
eureka:
  client:
    register-with-eureka: false 
    fetch-registry: false
    service-url:
      defaultZone: http://localhost:8302/eureka/
  server:
    wait-time-in-ms-when-sync-empty: 0   

客户端应用程序.yml

eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://localhost:8302/eureka/
  instance:
    hostname: localhost
spring:
  application:
    name: my-service
server:
  port: 8301

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 我用用户名和密码试过了,还是一样的问题
    猜你喜欢
    • 2020-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-18
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多