使用网关Zuul的时候,报java.lang.NoSuchMethodError: org.springframework.boot.web.servlet.error.ErrorController.getErrorPath()Ljava/lang/String;错误解决
最近遇到一个困扰了我很久的问题(关于Zuul):
报错界面如下:
原因是因为:Zuul与SpringBoot版本冲突,而SpringCloud又和SpringBoot版本关联,
SpringCloud与SpringBoot版本可以参考如下:
<dependency> <!-- 导入springCloud的依赖--> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Hoxton.SR12</version> <type>pom</type> <scope>import</scope> </dependency> <!-- SpringBoot--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.3.4.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency>
zuul以及eureka参看如下:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-zuul</artifactId> <version>2.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <version>2.2.5.RELEASE</version> </dependency>
配置好相应的Zuul测试环境,重新测试即可成功.