<!-- eureka服务依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency>
application.yml配置:
spring: application: name: eureka server: port: 8761 eureka: instance: hostname: localhost client: service-url: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ #设置eureka服务器所在地址,注册服务和查询服务都依靠这个地址 # 是否从eureka服务器获取注册信息 fetch-registry: false # 是否注册到eureka服务器 register-with-eureka: false
SpringBootApplication启动类下加注解@EnableEurekaServer