在idea中
还是老套路,加注解
高版本的需要加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
配置文件application,yml
spring:
application:
name: client
eureka:
client:
service-url:
defaultzone: http://localhost:8761/eureka/
instance:
hostname: clientname
访问http://localhost:8761
另外我测试的@EnableDiscoveryClient与@EnableEurekaClient,这2个注解都是可以的,如有问题,可用指出。
回到Eureka Server注册中心项目中,在application.yml加上eureka.server.enable-self-preservation:false配置,
注意只能在开发环境把它关闭,生成环境不要关闭了一定要打开,方便做微服务的调用,不会出现错误