Spring:錯誤No bean named 'xxxxxxx' available
首先說一些和這個無關的事情,在實習的過程中,我發現別人寫的程式碼方法名總喜歡用一樣的,
訪問資料庫的方法和控制器的方法名字都一樣;配置檔案中的命名和方法體中的成員也是一樣的名字。
我不喜歡,我覺得出了錯誤不好發覺,別人看的時候也容易看不懂。
對於我這種粗心的人很有必要。
貼出我的配置檔案
<bean id="action" class="entity.User_Action">
<property name="user_Se" ref="service"></property>
</bean>
<bean id="service" class="entity.User_Service">
<property name="user_Dao" ref="dao"></property>
</bean>
<bean id="dao" class="entity.User_Dao">
</bean>
ref引用的到底是誰???
引用的是這個配置檔案中id的值,我卻以為它引用的是類中的物件名。
name的值是什麼???
它的值是要set的成員名,這個我理解沒有錯。
public class User_Action { private User_Service user_Service; public void setUser_Se(User_Service user_Service) { this.user_Service = user_Service; } public String addUser() { user_Service.save(); return null; } }
public class User_Dao {
public void save() {
// TODO Auto-generated method stub
System.out.println("真正的連結資料庫");
}
}
public class User_Service {
private User_Dao user_Dao;
public void setUser_Dao(User_Dao user_Dao) {
this.user_Dao = user_Dao;
}
public void save() {
user_Dao.save();
}
}
有資料說出現這個錯誤是因為 初始化的順序原因,我覺得也有道理,反正就是找不到一個名字;
大家可以檢查一下是不是和我的問題一樣,做過一遍就覺得簡單了;
對了大家可能看我的程式碼眼熟,我是看視訊學的,感謝那位老師,哈哈哈,真心感謝。
相關文章
- spring中No bean named xxx available錯誤SpringBeanAI
- No bean named BookServiceImpl availableBeanAI
- idea maven搭建spring報錯:No bean named 'xxx' availableIdeaMavenSpringBeanAI
- No Bean named 'Xxx' available 異常報錯BeanAI
- No bean named ''XXX“ availableBeanAI
- 使用@Service註解出現No bean named 'xxxx' available]錯誤BeanAI
- Spring Boot學習之No bean named 'entityManagerFactory' available異常Spring BootBeanAI
- Caused by:.NoSuchBeanDefinitionException: No bean named 'userInfoServiceImpl' availableBeanExceptionAI
- Spring中出現:No bean named 'XXX' available問題解決SpringBeanAI
- spring-mybatis整合:NoSuchBeanDefinitionException: No bean named 'xxx.class' availableSpringMyBatisBeanExceptionAI
- 記一次idea構建springmvc報錯:No bean named 'cacheManager' availableIdeaSpringMVCBeanAI
- No bean named 'xxx' is defined錯誤,原因及解決方案Bean
- SpringBoot 學習之 No bean named ‘xxx’ availableSpring BootBeanAI
- Maven專案報錯:No bean named 'xxxxxx' availableMavenBeanAI
- spring getBean(String) No bean named '' is definedSpringBean
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'aaaa' availableSpringFrameworkBeanExceptionAI
- SpringMVC莫名其妙出現No bean named 'cacheManager' is defined錯誤SpringMVCBean
- spring配置檔案中配置了,但找不到Bean , 啟動不報錯,執行報錯No bean namedSpringBean
- 使用Idea構建springmvc框架,出現no bean named 'cacheManager' is defined 錯誤IdeaSpringMVC框架Bean
- 使用Idea構建springmvc框架,出現no bean named ‘cacheManager’ is defined 錯誤。IdeaSpringMVC框架Bean
- 報錯No bean named ' is defined的原因和解決方案Bean
- spring與mybatis中注入了卻總提示no bean namedSpringMyBatisBean
- kafka 錯誤: larger than available brokersKafkaAI
- Package ssh is not available, but is referred to by another package 錯誤PackageAI
- NBU available_media 命令執行錯誤AI
- pip安裝錯誤:ImportError: No module named 'pkg_resources'ImportError
- MyBatis對映錯誤:There is no setter for property named xxxMyBatis
- 程式碼改造引發的NoSuchBeanDefinitionException:no bean named 'XXXX' available問題解決方案BeanExceptionAI
- 【ERROR】su user報'This account is currently not available'錯誤 for linuxErrorAILinux
- No bean named 'cacheManager' availablej 異常解決BeanAI
- 報錯:org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'xxx'is definedSpringFrameworkBeanException
- 編譯實體Bean出現如下錯誤.....編譯Bean
- spring錯誤彙總Spring
- rrdtool命令錯誤,libpng12.so.0: no version information availableORMAI
- pyecharts安裝後import錯誤 ImportError: No module named 'pyecharts_snapshot'EchartsImportError
- [Spring]BeanSpringBean
- spring中bean.xml的http://www.springframework.org/schema/bean報錯SpringBeanXMLHTTPFramework
- springboot註解實現非同步呼叫時no bean of type TaskExecutor and no bean named 'taskExecutor' eitherSpring Boot非同步Bean