新建项目spring-cloud-zuul-service
org.springframework.cloud
spring-cloud-starter-zuul
开启服务注册
在程序的启动类 ZuulApplication
通过 @EnableZuulProxy
开启 Zuul 服务网关
@EnableZuulProxy
@SpringBootApplication
public class ZuulApplication {
public static void main(String[] args) {
SpringApplication.run(ZuulApplication.class, args);
}
}
添加配置
配置文件 application.yml
spring:
application:
name: zuul-service
server:
port: 9000
zuul:
routes:
blog:
path: /ymq/**
url: http://www.xxx.io/about