[英]Zuul proxy not routing
While working on spring Microservices I am not able to route api through zuul proxy 在春季微服务上工作时,我无法通过zuul代理路由api
This is my code 这是我的代码
eurka: eurka:
application.yml application.yml
spring:
application:
name: api
cloud:
config:
enabled: true
server:
port: ${PORT:8761}
eureka:
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
instance:
hostname: localhost
zuul: zuul:
application.yml application.yml
spring:
application:
name: proxy-server
server:
port: 8079
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka
fetchRegistry: true
zuul:
ignored-services: '*'
prefix: /api
routes:
account:
path: /account/**
serviceId: account
stripPrefix: false
host:
socket-timeout-millis: 30000
ribbion:
eureka:
enabled: true
account application.yml 帐户application.yml
ribbion:
eureka:
enabled: true
eureka:
instance:
preferIpAddress: true
client:
serviceUrl:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
instance:
preferIpAddress: true
dependency: 依赖性:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Now the url localhost:8080/user/
is working fine but localhost:8080/api/account/user/
is throwing a 404. 现在,URL
localhost:8080/user/
可以正常工作,但是localhost:8080/api/account/user/
则抛出404。
Not sure what wrong I am doing here, any insight will be helpful please let me know if you need other details 不确定我在这里做错什么,任何见解会有所帮助,如果您需要其他详细信息,请告诉我
What you need to do is, 您需要做的是
@EnableZuulProxy
@EnableZuulProxy
注释主类 application.properties
file application.properties
文件中配置路由和端点 I suggest to implement the above steps first and make them work. 我建议首先执行上述步骤并使它们起作用。 Then customize that project as per your need.
然后根据您的需要自定义该项目。 Found below article explaining the above steps with more details.
在下面的文章中找到了上述步骤的详细说明。 How to build an API-Gateway with Netflix Zuul + Spring Boot
如何使用Netflix Zuul + Spring Boot构建API网关
I think you forgotten to add the name the of account service in account application.yml 我认为您忘记在帐户application.yml中添加帐户服务的名称
spring:
application:
name: account
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.