[英]Micro-Service Architecture, Should the Spring Cloud Config Server, Zuul Gateway Server and Eureka Server be protected as Resources?
[英]Netflix eureka client micro-service is not registering with eureka server
我正在尝试使用eureka服务器注册我的微服务。 但它显示浏览器中没有可用的实例。 我在控制台中没有出现任何错误。 请帮我解决这个问题。
我已经通过谷歌搜索尝试了多个选项。 不过,我无法解决这个问题。
微服务application.properties
spring.application.name=jecreations-core
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
eureka.client.register-with-eureka=true
客户主类
@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.client.register-with-eureka=false
eureka.client.fetch-registry=false
server.port=8761
spring.application.name=DiscoveryServer
尤里卡服务器主类。
@SpringBootApplication
@EnableEurekaServer
public class JeeurekaApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(JeeurekaApplication.class, args);
}
}
您需要使用标注eureka服务器主类
@SpringBootApplication
@EnableEurekaServer
@EnableDiscoveryClient
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
此外,您需要使用以下内容注释客户端的主类:
@SpringBootApplication
@EnableDiscoveryClient
public class MicroApplication {
public static void main(String[] args) {
SpringApplication.run(MicroApplication.class, args);
}
}
您需要在eureka客户端的application.yml中进行以下配置:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
在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
试试这样吧
eureka服务器配置
eureka.client.registerWithEureka= false
eureka.client.serviceUrl.defaultZone= ${EUREKA_URI:http://localhost:8761/eureka}
eureka客户端配置
eureka.client.serviceUrl.defaultZone= http://localhost:8761/eureka
eureka.instance.preferIpAddress= true
仍然面临问题请关注我的回复https://github.com/vimaleshJeyavelmani/spring-boot-micros
谢谢,
Vimalesh
问题在于尤里卡客户的依赖性。 我已经给了这种依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-eureka-client</artifactId>
</dependency>
代替
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
谢谢你的回复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.