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:
    在這裏插入圖片描述

解決方式,引入上述依賴即可

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