SpringCloud Feign 启动报错

我就是我 2022-05-14 08:53 375阅读 0赞

本人用的工具是 Spring Tools Suite

在测试springcloud feign 时 ,

添加依赖如下:

  1. <parent>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-parent</artifactId>
  4. <version>1.5.4.RELEASE</version>
  5. </parent>
  6. <dependencies>
  7. <!-- Spring Cloud Netflix Eureka Server 依赖 -->
  8. <dependency>
  9. <groupId>org.springframework.cloud</groupId>
  10. <artifactId>spring-cloud-starter-eureka</artifactId>
  11. </dependency>
  12. <!-- Spring Boot Test 依赖 -->
  13. <dependency>
  14. <groupId>org.springframework.boot</groupId>
  15. <artifactId>spring-boot-starter-test</artifactId>
  16. <scope>test</scope>
  17. </dependency>
  18. <dependency>
  19. <groupId>org.springframework.boot</groupId>
  20. <artifactId>spring-boot-starter-web</artifactId>
  21. </dependency>
  22. <!-- 开启feign -->
  23. <dependency>
  24. <groupId>org.springframework.cloud</groupId>
  25. <artifactId>spring-cloud-starter-openfeign</artifactId>
  26. <version>2.0.0.RELEASE</version>
  27. </dependency>
  28. <!-- 热部署 -->
  29. <dependency>
  30. <groupId>org.springframework.boot</groupId>
  31. <artifactId>spring-boot-devtools</artifactId>
  32. <optional>true</optional>
  33. <scope>true</scope>
  34. </dependency>
  35. <!-- 监控机制 -->
  36. <dependency>
  37. <groupId>org.springframework.boot</groupId>
  38. <artifactId>spring-boot-starter-actuator</artifactId>
  39. </dependency>
  40. </dependencies>
  41. <dependencyManagement>
  42. <dependencies>
  43. <!-- Spring Cloud Netflix 依赖 -->
  44. <dependency>
  45. <groupId>org.springframework.cloud</groupId>
  46. <artifactId>spring-cloud-netflix</artifactId>
  47. <version>1.3.1.RELEASE</version>
  48. <type>pom</type>
  49. <scope>import</scope>
  50. </dependency>
  51. </dependencies>
  52. </dependencyManagement>
  53. <!-- 添加spring-boot-maven-plugin: -->
  54. <build>
  55. <plugins>
  56. <plugin>
  57. <groupId>org.springframework.boot</groupId>
  58. <artifactId>spring-boot-maven-plugin</artifactId>
  59. <configuration>
  60. <!--fork : 如果没有该项配置,可能devtools不会起作用,即应用不会restart -->
  61. <fork>true</fork>
  62. </configuration>
  63. </plugin>
  64. </plugins>
  65. </build>

接着启动报如下错误

  1. Caused by: java.lang.ClassNotFoundException: org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory
  2. at java.net.URLClassLoader.findClass(Unknown Source)
  3. at java.lang.ClassLoader.loadClass(Unknown Source)
  4. at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  5. at java.lang.ClassLoader.loadClass(Unknown Source)
  6. ... 29 more

找不到 LoadBalancedRetryFactory 这个类 , 之后自己检测了jar包之后,确实没有这个包

之后想了一些办法, 重新去 mavenrepository.com上面找了 feign 一个低版本的依赖

org.springframework.cloud
spring-cloud-starter-openfeign
1.4.5.RELEASE

重新启动, 发现启动成功.

springcloud中 , 大部分启动报错 添加依赖报错 一般都是由于依赖版本问题导致的错误.

发表评论

表情:
评论列表 (有 0 条评论,375人围观)

还没有评论,来说两句吧...

相关阅读