如何通过zuul代理从一个微服务访问另一个
我正在开发使用弹簧引导的微服务项目。 在这里,UI页面在独立的微服务和单独的微服务中的zuul代理。 我想通过zuul微服务访问UI页面。 我在下面添加了我的项目结构。
UiService Application.properties:
server.port=8090 spring.mvc.view.prefix: /WEB-INF/views/ spring.mvc.view.suffix: .jsp spring.application.name=ui eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/ eureka.instance.preferIpAddress=true eureka.instance.leaseRenewalIntervalInSeconds=5
zuulService application.yml:
server: port: 8080 eureka: instance: leaseRenewalIntervalInSeconds: 10 statusPageUrlPath: /info healthCheckUrlPath: /health logging: level: ROOT: INFO org.springframework.web: DEBUG zuul: routes: ui: url: http://localhost:8090 ribbon: eager-load: enabled: false
我的docker撰写文件:
version: '3' services: eureka: build: eurekaService ports: - "8761:8761" zuul: build: zuulService links: - eureka ports: - "8080:8080" turbine: build: turbineService links: - eureka ports: - "8989:8989" ui: build: uiService links: - eureka ports: - "8090:8090"
uiService结构:
我的尤里卡服务页面:
在docker(docker-compose up -d)中运行这个项目后,当我试图访问login屏幕(这是可用的内部uiService)得到以下exception。 如何解决这个问题?
UIService主要方法:
@SpringBootApplication @EnableDiscoveryClient @EnableCircuitBreaker public class UIApplication { public static void main(String[] args) { SpringApplication.run(UIApplication.class, args); } }
uiService pom.xml:
<modelVersion>4.0.0</modelVersion> <parent> <groupId>com.scm</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>uiService</artifactId> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-ribbon</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</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-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> </dependencies> </project>
localhost:8090/login
是对UI应用程序的直接请求,不涉及Zuul。
如果没有加载/显示页面,则在启动应用程序或/login
不存在错误。
你介意分享日志吗?