SpringCloud------搭建注册中心Eureka
1.Eureka图片概述
2.添加依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
3.添加服务注册中心配置
/src/main/resources/application.yml
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
registerWithEureka: true
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
#server:
#enable-self-preservation: false
spring:
application:
name: shop-server
4.添加启动类注解
@SpringBootApplication @EnableEurekaServer public class ShopServerApplication { public static void main(String[] args) { SpringApplication.run(ShopServerApplication.class, args); } }
5.启动项目
访问Url
http://localhost:8761/
如图: