1. 程式人生 > >實操:Could not autowire No beans of 'FastDFS Client' type found 的解決方法

實操:Could not autowire No beans of 'FastDFS Client' type found 的解決方法

前言:

今天接手了同事之前做的一個小專案,裡面涉及到了 FastDFS 的使用。但是當我在本地執行專案的時候,卻報了 Could not autowire No beans of 'FastDFS Client' type found 相關的錯誤。

接下來就詳細描述一下 FastDFS 報錯的解決方法。

一、問題描述

啟動 Application 類報錯:

required a bean of type 'org.springframework.fasfdfs.server.FastDFSClient' that could not be found.

二、問題分析

如下圖所示:根據報錯資訊發現,並不缺少 jar 包,報錯提示裡所需要的類也有,不知道為什麼會報錯。

綜上所述,再結合同事可以通過 idea 來正常執行,所以懷疑是 FastDFS 相關 jar 包可能存在依賴衝突。

三、解決辦法

1、首先將 Maven 倉庫中 FastDFS 相關 jar 包刪除,共兩個,分別是:fastdfs-client-java-1.27-SNAPSHOT.jar 和 spring-boot-starter-fastdfs-1.0-SNAPSHOT.jar ,其中後者依賴前者。

2、由於無法從中央倉庫中下載 FastDFS 的上述 jar 包,所以需要手動構建原始碼生成 jar 檔案。下載 fastdfs-client-java 和 spring-boot-starter-fastdfs 原始碼到本地,配置好原始碼專案的 Maven 地址後,執行 mvn clean install ,執行成功後,對應的 Maven 倉庫中就自動有了上述兩個 jar 包。需要特別說明的是:需要先打 fastdfs-client-java 的 jar 包,因為 spring-boot-starter-fastdfs 專案打包依賴 fastdfs-client-java-1.27-SNAPSHOT.jar 。

3、採用 Invalidate and Restart 的方式來重啟 idea ,這樣可以讓 idea 重新載入專案。

4、再重新執行 FastDFS 專案,啟動成功!

關於 fastdfs-client-java 和 spring-boot-starter-fastdfs 的原始碼程式我已經上傳到了百度雲,可私信本微信公眾號【大資料實戰演練】回覆 190917 獲取,或者自己在 github 等開源社群上找,都可以。

四、總結

1、問題小結

關於這個問題我進行了反覆測試,假如自己有 fastdfs-client-java-1.27-SNAPSHOT.jar 和 spring-boot-starter-fastdfs-1.0-SNAPSHOT.jar 包,採用

mvn install:install-file -Dfile="xxx.jar" -DgroupId=xxx -DartifactId=xxx -Dversion=xxx -Dpackaging=jar

的形式將本地 jar 包匯入到 Maven 倉庫中。雖然可以成功匯入,但啟動專案依舊會報上述錯誤,所以最穩妥的方式還是下載原始碼並打包,通過這樣的方式將需要的 jar 包匯入到 Maven 倉庫中。

2、maven 相關命令簡介

  • mvn clean : 清空編譯檔案
  • mvn test : 執行測試用例
  • mvn compile : 編譯專案
  • mvn package : 打包專案
  • mvn install : 安裝 jar 包到 Maven 的本地倉庫中

注意點:執行 mvn test ,會先執行 mvn compile ;執行 mvn package ,會先執行 mvn compile 和 mvn test ;執行 mvn install ,會先執行 mvn package 。


相關推薦

Could not autowire No beans of 'FastDFS Client' type found解決方法

前言: 今天接手了同事之前做的一個小專案,裡面涉及到了 FastDFS 的使用。但是當我在本地執行專案的時候,卻報了 Could not autowire No beans of 'FastDFS Client' type found 相關的錯誤。 接下來就詳細描述一下 FastDFS 報錯的解決方法。

【ActiveMQ】消息生產者自動註入報錯Could not autowire. No beans of 'JmsMessagingTemplate' type found

註入 fin producer 定義 red because spl send code 使用ActiveMQ過程中,定義消息生產者: package com.sxd.jms.producer; import org.springframework.beans.fa

IntelliJ idea 報錯Could not autowire,no beans of "XXX" type found

pan 踩坑 blog beans tail war 詳情 參考 spec Question:使用 IDEA 開發Java web項目時,在註解 @Autowired 裝配 dao 時顯示:Could not autowire,no beans of "XXX" type

【ActiveMQ】訊息生產者自動注入報錯Could not autowire. No beans of 'JmsMessagingTemplate' type found

標籤:public   style   hat   and   報錯   require   core &nb

IntelliJ Idea解決Could not autowire. No beans of 'xxxx' type found的錯誤提示

images clas sql figure war configure 多少 錯誤提示 bsp 本文轉自:http://blog.csdn.net/u012453843/article/details/54906905 1.問題描述   在Idea的spring工程裏

Could not autowire. No beans of 'TbItemMapper' type found. less... (Ctrl+F1) Checks autowiring prob

auto ould could 圖片 http bit bsp inf setting Intellij Idea開發工具在@Autowired或者@Resource註入XxxMapper接口時報如下錯誤: Could not autowire. No beans of ‘

IDEA解決"Could not autowire. No beans of 'xxxx' type found"的錯誤提示

創建 myba wire 配置 bean 問題 意思 per 路徑 使用IDEA開發Spring Boot項目的時候,利用註解的方式整合Mybatis。在運行的時候有可能會出現"Could not autowire. No beans of ‘xxxx‘ type foun

idea取消could not autowire. no beans of 'xxxx' type found的錯誤提示

在Idea的spring工程裡,經常會遇到Could not autowire. No beans of 'xxxx' type found的錯誤提示。但程式的編譯和執行都是沒有問題的,這個錯誤提示並不會產生影響。但紅色的錯誤提示在有些有強迫症的程式設計師眼裡,多多少少有些不太舒服。 &n

intellij IDEA 下解決 IDEA 下Could not autowire. No beans of 'ICpuBidOpenService' type found(後面內容是我轉載的)

1.問題描述   在Idea的spring工程裡,經常會遇到Could not autowire. No beans of 'xxxx' type found的錯誤提示。但程式的編譯和執行都是沒有問題的,這個錯誤提示並不會產生影響。但紅色的錯誤提示在有些有強迫症的程式設計師眼裡,多多少少有

Could not autowire. No beans of 'Mapper' type found.

首先你要判斷是的是否注入進來了 一種是我沒有注入進來報錯(執行報錯) 第二種是注入進來了,可以正常執行,但是這個紅色的提示看著看著不爽     方法: 第一種是包掃描的問題 配置檔案中沒有掃描到xml,仔細檢視 sprignboot的Appli

IDEA完美解決 Could not autowire. No beans of 'xxx' type found.報錯

對於IDEA這個提示功能,度孃的回答基本上空前的一致,大多數的說法都是要求我們把這個提示功能關閉,對此對於我這種非處女座卻有著比處女座更勝強迫症的程式設計師來說,這簡直不能忍????? 多說都是廢話,解決方法方法1:在mapper檔案上加@Repository註解,這是從

使用 @Resource或@Autowire時 Idea報錯Could not autowire. No beans of 'xxxService' type found. more..出現紅色波浪線

錯誤:  使用註解@Resource或者@Autowire intellij Idea報錯Could not autowire. No beans of 'xxxService' type found

IntelliJ Idea解決Could not autowire. No beans of 'xxxx' type found的錯誤提示

1.問題描述   在Idea的spring工程裡,經常會遇到Could not autowire. No beans of 'xxxx' type found的錯誤提示。但程式的編譯和執行都是沒有問題的,這個錯誤提示並不會產生影響。但紅色的錯誤提示在有些有強迫症的程式設計師

SpringBoot整合MyBatis——Could not autowire.No beans of 'xxxMapper' type found.(期待網友共同編輯)

遇到這個問題困擾了我好幾天,其實之前剛開始學習SpringBoot與MyBatis整合的時候,也遇到過這個問題。現在是第二次犯這個錯誤了,然而卻不是明知故犯,是慢慢被自己坑進來的。讓我們來看一下這個問題吧。可能總結的不是很全面,歡迎各位給我指出來,讓解決該類問題

【JAVA】Intelij IDEA 使用筆記——Could not autowire. No beans of 'xxxx' type found的錯誤提示

待補充……   ——安裝SVN:     IDEA的SVN(Subversion)使用時,需要先【Add to VCS(可能是我新建class的時候沒有add to vcs)】再【Commit file(提交)】;     更新工程是【Update file】;   ——安裝tomcat 8;   

IDEA引入dao介面,Could not autowire. No beans of 'UserMapper' type found

問題描述 使用了一段時間的Eclipse做開發,聽業界對IDEA的評價蠻高,所以想用IDEA搭建一個框架出來,並做開發,但是這個東西並沒有我想象的那麼友好,本來一個簡易的框架很容易就能夠搭建起來的,但是弄了很

IDEA下Could not autowire, No beans of XX type Found

一:問題背景.        1.1 IDEA下使用Kafka的KafkaTemplate時,引入依賴,,也是可以正常完成功能的.但是報一個紅色的波浪線,看上去有些不舒服吶.     &n

IntelliJ Idea 解決 Could not autowire. No beans of 'xxxx' type found 的錯誤提示

IntelliJ Idea 解決 Could not autowire. No beans of ‘xxxx’ type found 的錯誤提示 哈,在使用 @Autowired 時,今天又遇一坑,這倆波浪線是幹啥子嘛: 然鵝,試了一下,控制檯也不報錯,可以正常執行,

IDEA出現Could not autowire. No beans of 'xxx' type found.解決

刪除 edit tin type struct img ... png 出現 Plan A File → Project Structure... Facets → Spring → 右鍵刪除即可 Plan B File → Settings → Editor →

mybatis+spring boot, mapper 提示Could not autowire. No beans oftype found

工具及背景: IntelliJ IDEA 2017.1.3 Ultimate。spring boot, maven專案,利用mybatis 註解的方式查詢mysql。 業務邏輯關係:controller --> Service介面 ----> ser