there are two routing configurations in zuul:
1. Map
by accessing IP and port Numbers
2. Map
by service name
p>
based on the code in the previous section:
first I cluster both service providers and service consumers:
p>
first configure the first:
change gateway application.yml
server:
port: 8090
eureka:
client:
service-url:
default-zone: http://localhost:8761/eureka
spring:
application:
name: zuul-service
zuul:
routes:
feign:
path: /feign/**
url: http://localhost:8085/
accesses the path path through path and url mapping and accesses the url directly to the address corresponding to the url, which is obviously not good, because the address of the service must be known, and the number of clusters may be dynamically extended, which only realizes proxy forwarding and cannot realize load balancing. Where /feign/* represents only one path, /feign/* represents the following multiple paths
accessed through the gateway:
p>
let’s look at the second one:
The
profile is as follows:
server:
port: 8090
eureka:
client:
service-url:
default-zone: http://localhost:8761/eureka
spring:
application:
name: zuul-service
zuul:
routes:
api-a:
path: /feign/**
service-id: eureka-feign
#zuul:
# routes:
# feign:
# path: /feign/**
# url: http://localhost:8085/
now that you are registered on eureka, you should get the registered service information, access the micro service through the service id, write the service name here with the service-id, and also implement the routing and melting functions.
p>
is then accessed through the gateway:
p>
and the third: zuul.routes. Service name: access path
zuul:
routes:
eureka-feign: /feign/**
p>
if you ignore a micro service and do not use the gateway, set this:
p>
zuul:
#忽略某个微服务
ignored-services: eureka-feign
forward jumps to local url:
zuul.routes.api-a.path=/user/**
zuul.routes.api-a.url=forward:/user
routing prefix:
zuul.prefix
does not take effect by default. To take effect, zuul.stripprefix =false
sets the omitted prefix to false
zuul.routes.api-a.path=/user/**
zuul.routes.api-a.stripPrefix=false
if you want to configure routing rules in order, you must use the yml file, not the properties file
zuul:
routes:
users:
path: /user/**
others:
path: /**
p>
my github address
p>
Read More:
- Eureka starts abnormally and prompts FreeMarker template error
- java.lang.IllegalStateException : unable to read meta data for class
- [Solved] Error in registering Eureka for spring cloud micro service: classnotfoundexception: org.apache.http.conn.scheme.schemeregistry
- Resolve zuul the HTTP status 500 – internal server error error error displayed after startup
- Common errors reported by Eureka in spring cloud
- Why must microservices have gateways?
- When the springcloud obtains the cloud link database information, an error is reported: errorcode 1045, state 28000
- Solve the java.net.connectexception: connection rejected: connect error
- After introducing security, the service cannot be registered with Eureka
- Eureka failed to register error: saw local status change event statuschangeevent
- Notes on @ pathvariable annotation in springcloud openfeign
- Caused by: java.lang.IllegalStateException: Ambiguou There is already ‘XXXXXXController‘ bean method
- Java — one of Apollo configuration centers — Introduction to Apollo
- java.lang.AbstractMethodError: Receiver class com.alibaba.cloud.sentinel.feign.SentinelContractHolde
- Feignexception $unauthorized is reported by introducing security call service
- Eureka server startup error: cannot execute request on any known server
- Difference between routermodule.forroot and routermodule.forchild
- How to Configure Inter VLAN Routing on Layer 3 Switches?
- Jenkins docker push to harbor to report error
- Remember a feign error: feign.FeignException : status 404 reading XXXClient#XXMethod(Long)