Netflix eureka 客户端微服务未向 eureka 服务器注册
Netflix eureka client micro-service is not registering with eureka server
我正在尝试向 eureka 服务器注册我的微服务。但它显示浏览器中没有可用的实例。我在控制台中没有收到任何错误。请帮我解决这个问题。
我已经通过搜索 google 尝试了多个选项。尽管如此,我还是无法解决问题。
微服务application.properties
spring.application.name=jecreations-core
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
eureka.client.register-with-eureka=true
客户端主class
@EnableEurekaClient
@SpringBootApplication
@EnableConfigurationProperties(ImageProperties.class)
public class JecreationsApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(JecreationsApplication.class, args);
}
}
尤里卡服务器application.properties
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
server.port=8761
spring.application.name=DiscoveryServer
尤里卡服务器主class。
@SpringBootApplication
@EnableEurekaServer
public class JeeurekaApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(JeeurekaApplication.class, args);
}
}
您需要用
注释 eureka 服务器 main class
@SpringBootApplication
@EnableEurekaServer
@EnableDiscoveryClient
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
此外,您需要在客户的主要 class 中添加注释:
@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.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
问题依旧,请关注我的repo
https://github.com/vimaleshJeyavelmani/spring-boot-micros
谢谢,
维玛莱斯
问题出在 eureka 客户端的依赖性上。
我给了这个依赖
<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>
感谢您的回复。
我正在尝试向 eureka 服务器注册我的微服务。但它显示浏览器中没有可用的实例。我在控制台中没有收到任何错误。请帮我解决这个问题。
我已经通过搜索 google 尝试了多个选项。尽管如此,我还是无法解决问题。
微服务application.properties
spring.application.name=jecreations-core
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
eureka.client.register-with-eureka=true
客户端主class
@EnableEurekaClient
@SpringBootApplication
@EnableConfigurationProperties(ImageProperties.class)
public class JecreationsApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(JecreationsApplication.class, args);
}
}
尤里卡服务器application.properties
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
server.port=8761
spring.application.name=DiscoveryServer
尤里卡服务器主class。
@SpringBootApplication
@EnableEurekaServer
public class JeeurekaApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(JeeurekaApplication.class, args);
}
}
您需要用
注释 eureka 服务器 main class@SpringBootApplication
@EnableEurekaServer
@EnableDiscoveryClient
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
此外,您需要在客户的主要 class 中添加注释:
@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.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
问题依旧,请关注我的repo https://github.com/vimaleshJeyavelmani/spring-boot-micros
谢谢,
维玛莱斯
问题出在 eureka 客户端的依赖性上。 我给了这个依赖
<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>
感谢您的回复。