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

雜記——4.書寫spring時出現(xiàn)的Error creating bean with name ‘user0‘ defined in file錯誤

這篇具有很好參考價值的文章主要介紹了雜記——4.書寫spring時出現(xiàn)的Error creating bean with name ‘user0‘ defined in file錯誤。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

目錄

1.問題描述

2.情況描述:

3. 解決方法

4. 問題原因?


1.問題描述

當我們運行一個spring程序時,出現(xiàn)下圖的錯誤:

unsatisfied dependency expressed through constructor parameter 0; nested exc,問題與雜記,spring,java,后端

重點語句:

?Error creating bean with name 'user011' defined in file [D:地址]:? Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'int' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

2.情況描述:

當你在練習使用注解開發(fā)時,你寫的類和注解如下圖所示:

unsatisfied dependency expressed through constructor parameter 0; nested exc,問題與雜記,spring,java,后端

?你的xml文件內(nèi)容,如下圖所示:

unsatisfied dependency expressed through constructor parameter 0; nested exc,問題與雜記,spring,java,后端

你的測試方法如下圖所示:

unsatisfied dependency expressed through constructor parameter 0; nested exc,問題與雜記,spring,java,后端

?所有代碼都正確,但是運行不出來。

3. 解決方法

注釋掉Bean類中的構(gòu)造方法,如下圖所示:

unsatisfied dependency expressed through constructor parameter 0; nested exc,問題與雜記,spring,java,后端

?再運行測試(截圖如下):

unsatisfied dependency expressed through constructor parameter 0; nested exc,問題與雜記,spring,java,后端

4. 問題原因?

spring在創(chuàng)建對象(IOC)的時候,使用的是無參構(gòu)造器,而自己寫的構(gòu)造法會覆蓋無參構(gòu)造器,導致spring創(chuàng)建對象的時候出現(xiàn)問題,從而報錯。

注意:除非是使用xml配置文件的方式中的用構(gòu)造器方法來對屬性注入值這種情況之外,寫spring程序時,任何時候都不要使用(要注釋掉)自己寫的構(gòu)造器,因為spring的底層使用的是無參構(gòu)造器,不注釋掉會出現(xiàn)問題的。文章來源地址http://www.zghlxwxcb.cn/news/detail-644198.html

到了這里,關(guān)于雜記——4.書寫spring時出現(xiàn)的Error creating bean with name ‘user0‘ defined in file錯誤的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

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

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

相關(guān)文章

  • springboot啟動的時候報錯:Error creating bean with name ‘********‘

    springboot啟動的時候報錯:Error creating bean with name ‘********‘

    今天寫了一個自定義sql查詢,在Test文件夾測試的時候沒有問題,但是但啟動項目的時候報錯,報錯圖片如下: 檢查了很多地方,發(fā)現(xiàn)不是mapperscan,或者是配置檔命名空間的問題,而是pom.xml里面的一個低級錯誤 這段代碼在springboot的test文件夾里面編寫,因為使用的是idea,當

    2024年02月06日
    瀏覽(23)
  • UnsatisfiedDependencyException: Error creating bean with name ‘subjectServiceImpl‘: Unsatisfied depe

    UnsatisfiedDependencyException: Error creating bean with name ‘subjectServiceImpl‘: Unsatisfied depe

    看xml所在的路徑不舒服(任性改資源路徑) 以為idea會幫我更新引用就以身試險了哈哈哈 報錯信息是bean出現(xiàn)了創(chuàng)建錯誤 查了網(wǎng)上大部分的博客,一一排除后還是報錯 網(wǎng)上大部分建議總結(jié)如下: 1:先去排查service實現(xiàn)層有沒有添加注解@service 2:檢查接口有沒有對應(yīng)的實現(xiàn)類,可能實

    2023年04月24日
    瀏覽(18)
  • Error creating bean with name ‘esUtils‘ defined in file

    Error creating bean with name ‘esUtils‘ defined in file

    ?報錯異常: ?背景: esUtils在common服務(wù)中、啟動media服務(wù)時候、報這個異常、后排查esUtils在啟動時候發(fā)生異常引起的、在相關(guān)bean中加入try{}catch{}即可解決問題

    2024年02月11日
    瀏覽(33)
  • 解決Error creating bean with name ‘XXXX‘ defined in URL

    遇到了一個神奇的bug,在開發(fā)環(huán)境能好好運行的jar,到生產(chǎn)環(huán)境啟動的時候報Error creating bean with name \\\'XXXX\\\' defined in URL的異常,并且每次都是報的同一個類找不到,試了各種方法都沒能解決,網(wǎng)上也找了很多資料基本無用,異常如下。 經(jīng)過多次猜測和嘗試,終于發(fā)現(xiàn)原因。原來是由

    2024年02月12日
    瀏覽(21)
  • springboot報錯Error creating bean with name ‘dataSource‘的解決方案

    問題描述: 在學習到黑馬的學成在線微服務(wù)項目時,運行內(nèi)容模塊的服務(wù)時報錯如下: 報錯異常分析: Spring應(yīng)用程序中名為“dataSource”的bean的依賴項注入存在問題。具體問題在于“dataSource”bean的“basicProperties”字段。此字段有一個未滿足的依賴項。 嵌套異常進一步解釋

    2024年02月11日
    瀏覽(31)
  • springboot與springcloud版本關(guān)系,BeanCreationException: Error creating bean with name

    添加注解@EnableFeignClients后報錯: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \\\'configurationPropertiesBeans\\\' defined in class path resource [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is

    2024年02月05日
    瀏覽(15)
  • [報錯解決](Error Creating bean with name ‘xxx‘)類問題解決思路

    [報錯解決](Error Creating bean with name ‘xxx‘)類問題解決思路

    遇到Error Creating bean with name ’ \\\'這類問題的解決思路 錯誤日志關(guān)鍵部分: 大意如下:不滿足依賴異常。創(chuàng)建名為’xxxMapper’的bean時出錯:通過字段’sqlSessionFactory’表達的不滿足的依賴項; spring配置文件中檢查包是否掃描,仔細檢查自己的配置文件里和相關(guān)的配置路徑。 在項

    2023年04月08日
    瀏覽(21)
  • Java報錯org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘XXX‘:

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

    在運行簡單的spring-boot框架程序的時候,遇到了一個錯誤org.springframework.beans.factory.BeanCreationException: Error creating bean with name \\\'XXX\\\': 起初就單純的以為是自動裝配出了問題,就沒放在心上,就硬是運行,結(jié)果就是沒有成功。 在檢查了自動裝配注解是否正確填寫為@Autowired。???

    2024年02月14日
    瀏覽(21)
  • Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘s

    ????????在練習一個springboot項目時,在執(zhí)行時出現(xiàn)了下面的報錯信息,找了好久都不知道怎么回事,因此,記錄下整個過程,從而鞭策如菜雞一樣的自己。我的問題是打包問題(刪除pom打包方式就可以了) 目? 錄 前言 1、報錯問題 2、解決過程 3、解決方式 4、總結(jié) Cause

    2023年04月22日
    瀏覽(29)
  • Error creating bean with name ‘kafkaTemplate‘ defined in class path resource

    Error creating bean with name ‘kafkaTemplate‘ defined in class path resource

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name \\\'org.springframework.boot.autoconfigure.kafka.KafkaAnnotationDrivenConfiguration\\\': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.kafka.Kafka

    2024年02月07日
    瀏覽(30)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包