1、GateAway怎么和eureka联合使用?
1.1、新建项目,引入gateaway依赖,引入eureka依赖,不用引入web
like this
File->new->project
一路next
第一步:
第二步:
maven或者gradle
其他的随意填
第三步:
eureka
gateaway
1.2、给启动类增加@EnableDiscoveryClient注解
like this
@EnableDiscoveryClient
@SpringBootApplication
public class GateawayApplication {
public static void main(String[] args) {
SpringApplication.run(GateawayApplication.class, args);
}
}
1.3、配置文件如下
server:
port: 8080
spring:
cloud:
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
application:
name: gateaway
# Eureka Server 配置
eureka:
client:
serviceUrl:
defaultZone: http://localhost:2333/eureka/
对配置文件说明:
spring:
cloud:
gateway:
discovery:
locator:
enabled: true // 开启路由到eureka中注册的服务
lower-case-service-id: true // 允许使用小写的服务名
// 配置注册中心eureka的地址
eureka:
client:
serviceUrl:
defaultZone: http://localhost:2333/eureka/