赞
踩
搭建流程如下:
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</<dependencies>
3.启动器
@SpringBootApplication
@EnableEurekaServer //该注解表示当前应⽤为Eureka Server
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}
server: port: 9004 //当前服务的端口号 spring: application: name: eureka-server //注册到Eureka的服务名 eureka: client: service-url: # eureka 服务地址,如果是集群的话;需要指定其它集群eureka地址 defaultZone: http://127.0.0.1:9004/eureka # 是否注册到注册中心,默认为true # 当前为eureka server,无需注册自己 register-with-eureka: false # 是否从注册中心拉群服务列表,默认为true # 当前为eureka server,无需拉取列表 fetch-registry: false
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka- client</artifactId>
</dependency>
</dependencies>
@SpringBootApplication
@EnableDiscoveryClient //该注解表示当前应⽤为Eureka Client,即eureka的客户端
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
server:
port: 9002 //当前服务的端口号
spring:
application:
name: cloud-order-service //注册到Eureka的服务名,之后可作为当前服务的id使用
eureka:
client:
service-url:
# eureka 服务地址,如果是集群的话;需要指定其它集群eureka地址
defaultZone: http://127.0.0.1:9004/eureka
# 是否注册到注册中心,默认为true
# register-with-eureka: true
# 是否从注册中心拉群服务列表,默认为true
# fetch-registry: true
启动应⽤访问http://localhost:9004,效果如图所示。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。