1
我正在开发使用spring启动的微服务项目。在这里,UI页面在独立的微服务和独立的微服务中的zuul代理中。我想通过zuul微服务访问UI页面。我在下面添加了我的项目结构。如何通过zuul代理从一个微服务访问另一个微服务
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
我的搬运工撰写文件:
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"
uiSer副结构:
我尤里卡服务页面:
运行这个项目在泊坞窗(码头工人,组成了-d)之后,当我试图访问登录屏幕(在uiService中可用)获得以下异常。如何解决这个问题?
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>
一旦我涉及Zuul代理,同时显示登录页面,我得到了相同的页面作为结果(已附加SS)。 url:localhost:8080/ui/login .....在将镜像部署到docker(docker-compose up -d)时,我没有收到任何错误。 –
您介意共享:pom.xml,您使用的是Spring Boot版本,还是映射到GET/login的UIController? – ootero
我使用1.5.2版, getmapping是在uiController '@RequestMapping(值= “/登录”,方法= RequestMethod.GET) \t公共字符串getLogin(){ \t \t返回 “登录”; \t}' 上面,我已经添加了我的uiService pom.xml –