国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Java報錯org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘XXX‘:

這篇具有很好參考價值的文章主要介紹了Java報錯org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘XXX‘:。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

在運(yùn)行簡單的spring-boot框架程序的時候,遇到了一個錯誤org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXX':

起初就單純的以為是自動裝配出了問題,就沒放在心上,就硬是運(yùn)行,結(jié)果就是沒有成功。

在檢查了自動裝配注解是否正確填寫為@Autowired。???????

?

考慮到可能是@Autowired需要掃描的時間東西太多,導(dǎo)致某個注解可能遺漏,于是就將@Autowired更換為@Resource,

@Autowired是通過byType進(jìn)行尋找,找不到在通過byName尋找。缺點(diǎn)是效率低。

而@Resource會先按byName去找,如果沒找到則會byType去找。如果設(shè)置了name屬性,則只會按byName去找,找不到就報錯。

于是在運(yùn)行過后仍然報錯。說明不是注解的錯誤。

就去檢查代碼各層名字是否錯誤,注解是否漏寫。檢查下來發(fā)現(xiàn)沒有問題。

最后想到了打包發(fā)布的.xml文件要和接口層要在一個文件下,于是就去target里面進(jìn)行檢查。發(fā)現(xiàn)確實兩個文件在不同的目錄下面。于是將.xml的路徑設(shè)置成與接口文件相同路徑。

Java報錯org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘XXX‘:,java,spring,spring boot

最后運(yùn)行后,成功。文章來源地址http://www.zghlxwxcb.cn/news/detail-633006.html

到了這里,關(guān)于Java報錯org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘XXX‘:的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean (啟動項目報錯)

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean (啟動項目報錯)

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name \\\'shiroFilter\\\' defined in class path resource [com/cdzn/mhs/config/ShiroConfig.class]: Unsatisfied dependency expressed through method \\\'shiroFilter\\\' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with n

    2024年02月10日
    瀏覽(22)
  • 報錯org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name...

    報錯org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name...

    剛學(xué)SpringBoot,今天啟動的時候報錯了,長長的一堆報錯信息 報錯信息大概說的是創(chuàng)建UserController bean出現(xiàn)錯誤 下面又說創(chuàng)建UserService bean出現(xiàn)錯誤和UserMapper也出錯 于是我百度了一下,都說沒加注解,我檢查了一下,改加的都加了呀 于是我又分別測試了一下mapper和service 又說報

    2024年02月04日
    瀏覽(78)
  • 解決報錯:@org.springframework.beans.factory.annotation.Autowired(required=true)

    先把問題貼出來: @org.springframework.beans.factory.annotation.Autowired(required=true) 報這個錯是因為: @Autowired(required=true):當(dāng)使用@Autowired注解的時候,其實默認(rèn)就是@Autowired(required=true),表示注入的時候,該bean必須存在,否則就會注入失敗。 ** ** 解決辦法:

    2024年02月13日
    瀏覽(21)
  • SpringBoot項目報錯:org.springframework.beans.factory.UnsatisfiedDependencyException依賴注入異常(已解決)

    SpringBoot項目報錯:org.springframework.beans.factory.UnsatisfiedDependencyException依賴注入異常(已解決)

    ? ? ?? 目錄 報錯信息 可能原因 結(jié)論 ????????最近在學(xué)Spring Boot,今天在做Spring Boot + Mybatis Plus + Vue項目時啟動后端報錯: ? ? ? ? 先看報錯信息,說出現(xiàn)了一個 依賴注入異常(UnsatisfiedDependencyException) ,在創(chuàng)建名為 \\\'loginController\\\' 的bean時出錯,并且問題出現(xiàn)在字段 \\\'

    2024年02月11日
    瀏覽(25)
  • 已解決org.springframework.beans.factory.UnsatisfiedDependencyException org.springframework.beans.factor

    已解決org.springframework.beans.factory.UnsatisfiedDependencyException org.springframework.beans.factory.異常的正確解決方法,親測有效?。?! org.springframework.beans.factory.UnsatisfiedDependencyException org.springframework.beans.factor 對于 org.springframework.beans.factory.UnsatisfiedDependencyException 異常,通常是由于依賴注

    2024年02月05日
    瀏覽(20)
  • 關(guān)于org.springframework.beans.factory.NoSuchBeanDefinitionException

    關(guān)于org.springframework.beans.factory.NoSuchBeanDefinitionException

    這個報錯可能是因為: 1. spring的xml配置文件Bean中的id和getBean的id不一致 spring的配置文件中: 而程序中 applicationContext.getBean(“studenta”, Student.class)中的是studenta而spring配置文件的id是student,不一致。 2. 是否是忘記加注解了 @Resource或@Autowired都可以(@Resource是jdk自帶的) 3.如果

    2024年02月13日
    瀏覽(18)
  • Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException

    Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException

    修改為: ? ?解決辦法: BookDao層中添加@Mapper, 告訴springboot這是一個mybatis代理接口類型, 快來掃描我!, 由此生成代理對象 原因三:?? 測試類ModuleSetApplicationTests和引導(dǎo)程序ModuleSetApplication沒有在同名包下, 例如下圖, ModuleSetApplication類在com.itheima下ModuleSetApplicationTests沒有直接在com

    2024年02月11日
    瀏覽(26)
  • exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException

    exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException

    原因: Spring Boot異常org.springframework.beans.factory.NoUniqueBeanDefinitionException:沒有可用的合格Bean類型:預(yù)期匹配單個Bean,但是匹配到了多個,當(dāng)該bean被自動裝配時與Spring Boot應(yīng)用程序上下文中的兩個或多個加載的Bean匹配時,就會發(fā)現(xiàn)該異常。 Spring Boot允許從一個接口或抽象類創(chuàng)

    2024年02月09日
    瀏覽(30)
  • 異常:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name

    出現(xiàn)這種異常主要是無法創(chuàng)建bean到容器中,主要有以下幾種情況: 1.注解沒有添加: controller: 注: controller類要加入@RestController注解,@AllArgsConstructor注解視情況而定。 引入了private final IEnterpriseService service,所以需要注入,可以在controller類上加入@AllArgsConstrctor注解修飾。

    2024年02月21日
    瀏覽(20)
  • Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean wit

    是因為沒有掃描到 mapper,在啟動類或者配置類中@MapperScan配置包掃描,或者使用@Mapper注解Mapper接口

    2024年02月16日
    瀏覽(32)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包