[英]Netflix eureka client micro-service is not registering with eureka server
I am trying to register my microservice with the eureka server. 我正在尝试使用eureka服务器注册我的微服务。 But it shows no instances available in the browser. 但它显示浏览器中没有可用的实例。 I do not get any error in the console. 我在控制台中没有出现任何错误。 Please help me in resolving this. 请帮我解决这个问题。
I already tried multiple options by searching on google. 我已经通过谷歌搜索尝试了多个选项。 Still, I am unable to resolve the issue. 不过,我无法解决这个问题。
Microservice application.properties 微服务application.properties
spring.application.name=jecreations-core
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
eureka.client.register-with-eureka=true
client main class 客户主类
@EnableEurekaClient
@SpringBootApplication
@EnableConfigurationProperties(ImageProperties.class)
public class JecreationsApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(JecreationsApplication.class, args);
}
}
Eureka Server application.properties Eureka Server application.properties
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
server.port=8761
spring.application.name=DiscoveryServer
Eureka server main class. 尤里卡服务器主类。
@SpringBootApplication
@EnableEurekaServer
public class JeeurekaApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(JeeurekaApplication.class, args);
}
}
You need to annotate the eureka server main class with 您需要使用标注eureka服务器主类
@SpringBootApplication
@EnableEurekaServer
@EnableDiscoveryClient
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
Additionally you need annotate you client's main class with: 此外,您需要使用以下内容注释客户端的主类:
@SpringBootApplication
@EnableDiscoveryClient
public class MicroApplication {
public static void main(String[] args) {
SpringApplication.run(MicroApplication.class, args);
}
}
You need the below configuration in application.yml of the eureka client: 您需要在eureka客户端的application.yml中进行以下配置:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
In the Eureka Server application.yml file I have this configurations: 在Eureka Server application.yml文件中,我有以下配置:
info:
component: Eureka Server
server:
port: 8761
eureka:
client:
registerWithEureka: false
fetchRegistry: false
server:
enable-self-preservation: false
waitTimeInMsWhenSyncEmpty: 0
instance:
hostname: localhost
lease-expiration-duration-in-seconds: 15
lease-renewal-interval-in-seconds: 5
Try like this 试试这样吧
eureka server config eureka服务器配置
eureka.client.registerWithEureka= false
eureka.client.serviceUrl.defaultZone= ${EUREKA_URI:http://localhost:8761/eureka}
eureka client config eureka客户端配置
eureka.client.serviceUrl.defaultZone= http://localhost:8761/eureka
eureka.instance.preferIpAddress= true
Still facing the problem please follow my repo https://github.com/vimaleshJeyavelmani/spring-boot-micros 仍然面临问题请关注我的回复https://github.com/vimaleshJeyavelmani/spring-boot-micros
Thanks, 谢谢,
Vimalesh Vimalesh
The problem is with dependency of eureka client. 问题在于尤里卡客户的依赖性。 I have given this dependency 我已经给了这种依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-eureka-client</artifactId>
</dependency>
instead of 代替
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
Thanks for the responses. 谢谢你的回复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.