栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Eureka启动报错 Root name (‘timestamp‘) does not match expected type EurekaApplications

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Eureka启动报错 Root name (‘timestamp‘) does not match expected type EurekaApplications

文章目录
        • 1.Eureka启动报错
        • 2.解决方案
        • 3.Eureka服务端配置
        • 4.Eureka客户端配置
        • 5.问题

1.Eureka启动报错

最近在学习Eureka 启动客户端报错 , 查了网上一堆操蛋的回答

  1. 有些人说是开启了spring security csrf 认证控制,要加一个配置取消csrf认证
    我看我的配置都没引入spring security包啊,往哪里开启登录验证,扯淡呢
  2. 有些人说是eureka的url上要加 userName:password 我的eureka都没用户名密码,应该也不是这里的问题

如果你引入了spring security且设置了登录验证要加,所以根本问题不在这里

报错信息是
Root name (‘timestamp’) does not match expected (‘applications’) for type EurekaApplications

Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Root name (‘timestamp’) does not match expected (‘applications’) for type org.springframework.cloud.netflix.eureka.http.EurekaApplications
at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 2] (through reference chain: org.springframework.cloud.netflix.eureka.http.EurekaApplications[“timestamp”])

Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Root name ('timestamp') does not match expected ('applications') for type `org.springframework.cloud.netflix.eureka.http.EurekaApplications`
 at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 2] (through reference chain: org.springframework.cloud.netflix.eureka.http.EurekaApplications["timestamp"])
2.解决方案

Eureka要求你的serviceUrl 的后缀结尾必须是eureka
如果你写了别的就会出现上面的错误
我写的是 http://localhost:${server.port}/eurekajzj 就是错的

服务端和客户端保持一致 http://localhost:${server.port}/eureka 就可以

否则就会出现上面的错误

3.Eureka服务端配置

先是启动类EurekaServer
看下Server的配置

spring.application.name=eureka-server
server.port=8761

#eureka自动保护 关闭
eureka.server.enable-self-preservation=false

eureka.instance.hostname=eureka-hostname-jzj
#不能调用自己
eureka.client.fetch-registry=false
#不自己注册自己
eureka.client.register-with-eureka=false

eureka.client.service-url.defaultZone = http://localhost:${server.port}/eurekajzj

4.Eureka客户端配置
server.port=8088

#user服务
spring.application.name=user-client

#eureka注册中心地址
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eurekajzj
5.问题

问题就是 eurekajzj后缀
我的Eureka Server配置的 serviceUrl地址
eureka.client.service-url.defaultZone = http://localhost:${server.port}/eurekajzj
我的客户端配置的 eureka地址
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eurekajzj
后缀结尾不是eureka

修改后,Eureka服务及客户端全都正常

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/884467.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号