- 1.Eureka启动报错
- 2.解决方案
- 3.Eureka服务端配置
- 4.Eureka客户端配置
- 5.问题
最近在学习Eureka 启动客户端报错 , 查了网上一堆操蛋的回答
- 有些人说是开启了spring security csrf 认证控制,要加一个配置取消csrf认证
我看我的配置都没引入spring security包啊,往哪里开启登录验证,扯淡呢 - 有些人说是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/eurekajzj5.问题
问题就是 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服务及客户端全都正常



