ChaoBaby94 2018-03-17 05:06 采纳率: 0%
浏览 7854
已结题

eureka配置了spring security后,客户端启动报错,请求不到服务器

服务器端:
pom.xml添加的spring security
启动类添加了@EnableEurekaServer注解
yml如下
spring:
security:
user:
name: user
password: psw123
eureka:
client:
service-url:
defaultZone: http://user:psw123@localhost:8761/eureka
register-with-eureka: false
fetch-registry: false
客户端
pom添加spring-boot-starter-actuator依赖
启动类添加了@EnableDiscoveryClient注解
yml如下
eureka:
client:
service-url:
defaultZone: http://user:psw123@localhost:8761/eureka
instance:
prefer-ip-address: true
instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}

服务器端启动正常,输入ip后也能通过输入用户名密码登录。但是客户端启动则报错。
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
如果去掉spring security验证的话客户端是能够正常注册到注册中心的。
网上服务器的yml配置(如下),我这里是没有的。我这里只有spring.security,
没有直接就security。
security:
basic:
enable:true
name:
password

  • 写回答

2条回答 默认 最新

  • ?????983 2018-03-19 02:58
    关注

    management.context-path=/manage
    management.security.enabled=false
    management.port=9980
    /////这里开启安全认证以后默认所有组件都需要安全认证,包括客户端和eureka服务的之间的心跳,建议只有管理端口开启安全认证,业务端口不开启
    security.basic.enabled=true
    security.basic.path=/manage
    security.user.name=admin
    security.user.password=admin
    这样配置,把你的eureka管理端口和业务端口区分开

    评论

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?