日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

springboot 工程启动报错之Consider defining a bean of type ‘XXX’ in your configuration.

發(fā)布時間:2023/12/1 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 springboot 工程启动报错之Consider defining a bean of type ‘XXX’ in your configuration. 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

一、前言:

使用springboot自動注入的方式搭建好了工程,結果啟動的時候報錯了!!!,錯誤如下圖:

Description:Field userEntityMapper in com.xxx.xxx.service.UserService required a bean of type 'com.xxx.xxx.dao.UserEntityMapper' that could not be found.Action:Consider defining a bean of type 'com.xxx.xxx.dao.UserEntityMapper' in your configuration.

二、解決方式:

1.檢查自己寫的注解是否錯了,并沒有。

2.在網(wǎng)上查找解決方式:如下所示:

步驟一:

  在springboot的配置文件添加,mybatis的配置如下所示:

mybatis:typeAliasesPackage: com.xxx.xxx.dao.entitymapperLocations: classpath:mapper/*.xml

?步驟二:

  ①將接口與對應的實現(xiàn)類放在與application啟動類的同一個目錄或者他的子目錄下,這樣注解可以被掃描到,這是最省事的辦法。(沒測試)
 ?、诨蛘咴趩宇惿霞由?#64;MapperScan或者@ComponentScan注解,手動指定application類要掃描哪些包下的注解,如下所示:?

@SpringBootApplication @ComponentScan(basePackages = {"com.xxx.xxx.dao"})

 ?、刍蛘咴诮涌谏咸砑?#64;Mapper注解。

@Mapper public interface UserMapper { }

ps:之所以沒有找到對應的Bean是因為,@SpringBootApplication沒有掃描到。

參考:關于spring boot自動注入出現(xiàn)Consider defining a bean of type 'xxx' in your configuration問題解決方案

轉載于:https://www.cnblogs.com/louby/p/10436917.html

總結

以上是生活随笔為你收集整理的springboot 工程启动报错之Consider defining a bean of type ‘XXX’ in your configuration.的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。