Spring Boot Start Project Throw Exception CNF: org.springframework.http.ResponseEntity

问题描述

  1. 使用 SpringCloud 搭建的项目,现启动三个模块,register(注册中心)、gateway(网关)、user(用户服务),启动 user 时抛出异常:
ClassNotFoundException: org.springframework.http.ResponseEntity

查看导致的原因

  1. Spring Boot 项目在启动时,有个依赖是必须导入的,而在我引入的依赖中,并没有包含这个依赖:
<dependencies>
   <!--springboot web模块支持,自动帮我们引入了web模块开发需要的相关jar包-->
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
   </dependency>
</dependencies>

为什么 register、gateway 两个模块里面没有引入,启动却没有问题

  1. 原因在于,这两个模块引入的依赖中,已经包含了这个依赖,gateway 比较特殊,它包含的依赖是 webflux:
    在这里插入图片描述

解决方式,引入上述依赖即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章