spring cloud zuul网关

pom

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

 启动项

@SpringBootApplication
@EnableDiscoveryClient
@EnableZuulProxy
@RestController
public class ConsulzuulApplication {

// @RequestMapping("/hello")
// public String hello(){
//
// return null;
// }

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

配置文件

zuul.routes.consulserver.path=/consulserver/**
zuul.routes.consulserver.service-id=consulserver
server.port=8083
spring.application.name=consulzuul
spring.cloud.consul.port=8500
spring.cloud.consul.host=localhost
spring.cloud.consul.discovery.register=false
#zuul.routes.api-b.path=/api-b/**
#zuul.routes.api-b.service-id=api-b 
posted on 2018-11-28 17:05  ttke  阅读(111)  评论(0编辑  收藏  举报