11 个答案:
答案 0 :(得分:18)
我发现我必须添加这两个应用程序appllication.properties其中,它可以工作。只有一个是不够的。
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
答案 1 :(得分:5)
这个特定的消息只是一个警告。您的应用程序正在尝试Eureka注册,但Eureka没有回应。您可以添加以下内容application.yml来启动Eureka实例或禁止自动注册。
eureka:
client:
register-with-eureka: false
答案 2 :(得分:4)
您需要创建另一个微服务Eureka Registry Server。它是SpringBoot应用程序的主要类别应该有@EnableEurekaServer注释。
然后在您的Eureka你必须在客户端appliation.yml提到注册服务器URL,如下所示:
spring:
application:
name: stock-service
server:
port: 8083
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8084/eureka/
instance:
hostname: localhost
其中defaultzone应该包含你的Eureka Registry的值。
所有这些配置完成后,您需要启动Eureka Registry微服务只能启动Eureka客户端。一旦您的注册表启动,您将不会遇到此异常。
答案 3 :(得分:3)
当我的Eureka尝试客户端(即微服务)Eureka Server注册自己时,我也面临着同样的错误。
客户端注册eureka未能在任何已知服务器上执行服务失败的请求
这个错误的消息是由于以下两种可能性造成的。
1)defaultZone地址不正确,可能是拼写错误或后续空间:。
2)在Eureka实现在服务器上Spring安全要求每个请求都发送一个有效的请求CSRF令牌。尤里卡客户通常没有有效的跨网站要求伪造(CSRF)令牌。因此,您将需要针对/ eureka / **该要求禁止端点。
禁止使用以下代码行使用以下代码行CSRF令牌后,我的Eureka成功的客户端Eureka Server注册了自己。
@EnableWebSecurity
class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().ignoringAntMatchers("/eureka/**");
super.configure(http);
}
}
下面也是spring文档的链接。
答案 4 :(得分:1)
这种情况正在发生,因为它试图连接到任何已知服务器,所以停止错误,已知服务器在端口8761上eureka服务器默认端口,您必须使用以下服务器SELECT EMPLOYEE, CATEGORY, STATUS
FROM EMPLOYMENT
WHERE CATEGORY = 1 AND STATUS LIKE '%A%'
and employee in (select EMPLOYEE from EMPLOYMENT where
CATEGORY = 2 AND STATUS = 'B')
要避免eureka注册自己,请添加到其中application.properties
server.port=8761
确保启用了EurekaServer,例如使用spring boot主类写如下。
eureka.client.register-with-eureka=false
请原谅我的使用.properties文件提供解决方案,但这是我的工作,但是.yml配置不应太不同。
答案 5 :(得分:1)
假如你拼写了defaultZone值中的任何内容都会导致类似的错误。例如,有人把尤里卡拼写成euraka。仔细检查。
defaultZone : http://localhost:8761/eureka
答案 6 :(得分:1)
如果在没有用户名和密码的情况下部署/运行eureka请使用以下属性。
spring.application.name=Hello-World
eureka.client.serviceUrl.defaultZone=http://eurekaserver:password@localhost:9100/eureka
server.port=9200
eureka.client.fetch-registry=true
如果名和密码部署/运行eureka请使用以下属性。
spring.application.name=Hello-World
eureka.client.serviceUrl.defaultZone=http://eurekaserverusername:eurekaserverpassword@localhost:9100/eureka
server.port=9200
eureka.client.fetch-registry=true
答案 7 :(得分:0)
在ZuulLoggingFiler.java中查找filterType()。我有同样的问题。然后我看到我的过滤器返回null。所以我把它改为 post而且有效。
@Override
public String filterType() {
// TODO Auto-generated method stub
return "post";
}
答案 8 :(得分:0)
检查您的eureka服务器的URL和端口号
“ eureka.client.serviceUrl.defaultZone在属性中提供。
答案 9 :(得分:0)
对我来说,它可以在连接到互联网后正常工作,因为它需要第一次下载一些依赖项。
答案 10 :(得分:0)
确保您的功能区客户端正确
package com.in28minutes.microservices.currencyconversionservice;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@FeignClient(name="curreenter code herency-exchange-service")
@RibbonClient(name="currency-exchange-service")
public interface CurrencyExchangeServiceProxy {
@GetMapping("/currency-exchange/from/{from}/to/{to}")
public CurrencyConversionBean retrieveExchangeValue
(@PathVariable("from") String from, @PathVariable("to") String to); //mention correct pathvariables
}