1, consul

spring cloud 网管篇zuul_spring

 

 

2, zuul 程序的yml 文件

server:
  port: 8083
spring:
  application:
    name: zuulInfo # 应用名称
  cloud:
    consul:
      host: localhost
      port: 8500
      discovery:
        service-name: ${spring.application.name}
zuul:
  routes:
    test:
      url: http://localhost:8086
    api-a:
      path: /api-a/**
      serviceId: testInfo


3,zuul 程序的pom文件
<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>



4, zuul 程序注解
@EnableDiscoveryClient
@EnableZuulProxy
@SpringBootApplication
public class ZuulGateWayApplication {

   public static void main(String[] args) {
      SpringApplication.run(ZuulGateWayApplication.class, args);
   }

}