首页  

springboot2网关zuul实例     所属分类 springcloud 浏览量 1130
引入依赖

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


ZuulApplication.java

@SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy
public class ZuulApplication {
    public static void main(String[] args) {
        SpringApplication.run(ZuulApplication.class, args);
    }
}

application.properties

server.port=9036
server.servlet.context-path=/
spring.application.name=spring-cloud-zuul
eureka.client.service-url.defaultZone=http://127.0.0.1:9030/eureka/

#zuul.routes.api.path=/api/**
zuul.routes.api.prefix=api
zuul.routes.api.service-id=provider
zuul.routes.api.stripPrefix=true

#zuul.routes.api1.path=/api1/**
zuul.routes.api1.prefix=api1
zuul.routes.api1.service-id=provider
zuul.routes.api1.stripPrefix=true

stripPrefix=true , 把 前缀 去掉 ,转发给后端 服务实例

http://127.0.0.1:9036/api/serverInfo
http://127.0.0.1:9036/api1/serverInfo

stripPrefix=true 去掉 前缀 ,轮流转发给后端实例


微服务注册中心 服务提供者消费者 代码及使用
 springboot2微服务实例演示 

上一篇     下一篇
为啥GO不火

springboot2微服务实例演示

GO的垃圾特性

三体精句摘录

硬盘读写特性

linux configure --prefix 参数的作用