8

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

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

尤里卡服务应用程序.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
4

2 回答 2

9

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

于 2017-06-24T15:33:15.703 回答
0

我同意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
于 2017-11-21T17:56:55.160 回答