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
- idea maven搭建spring報錯:No bean named 'xxx' availableIdeaMavenSpringBeanAI
- 使用@Service註解出現No bean named 'xxxx' available]錯誤BeanAI
- No Bean named 'Xxx' available 異常報錯BeanAI
- No bean named ''XXX“ availableBeanAI
- No bean named BookServiceImpl availableBeanAI
- Maven專案報錯:No bean named 'xxxxxx' availableMavenBeanAI
- Caused by:.NoSuchBeanDefinitionException: No bean named 'userInfoServiceImpl' availableBeanExceptionAI
- spring-mybatis整合:NoSuchBeanDefinitionException: No bean named 'xxx.class' availableSpringMyBatisBeanExceptionAI
- Spring中出現:No bean named 'XXX' available問題解決SpringBeanAI
- SpringBoot 學習之 No bean named ‘xxx’ availableSpring BootBeanAI
- 記一次idea構建springmvc報錯:No bean named 'cacheManager' availableIdeaSpringMVCBeanAI
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'aaaa' availableSpringFrameworkBeanExceptionAI
- No bean named 'xxx' is defined錯誤,原因及解決方案Bean
- spring getBean(String) No bean named '' is definedSpringBean
- 使用Idea構建springmvc框架,出現no bean named ‘cacheManager’ is defined 錯誤。IdeaSpringMVC框架Bean
- spring配置檔案中配置了,但找不到Bean , 啟動不報錯,執行報錯No bean namedSpringBean
- 程式碼改造引發的NoSuchBeanDefinitionException:no bean named 'XXXX' available問題解決方案BeanExceptionAI
- kafka 錯誤: larger than available brokersKafkaAI
- 報錯:org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'xxx'is definedSpringFrameworkBeanException
- 【ERROR】su user報'This account is currently not available'錯誤 for linuxErrorAILinux
- No bean named 'cacheManager' availablej 異常解決BeanAI
- [mac pip錯誤]Can't connect to HTTPS URL because the SSL module is not availableMacHTTPAI
- pyecharts安裝後import錯誤 ImportError: No module named 'pyecharts_snapshot'EchartsImportError
- spring中bean.xml的http://www.springframework.org/schema/bean報錯SpringBeanXMLHTTPFramework
- [Spring]BeanSpringBean
- No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1BeanJavaSQLAIAST
- springboot註解實現非同步呼叫時no bean of type TaskExecutor and no bean named 'taskExecutor' eitherSpring Boot非同步Bean
- 記錄安裝conda install Python庫時報No module named ‘tensorflow‘錯誤Python
- spring事務常見錯誤Spring
- 七、Spring Boot 錯誤處理原理 & 定製錯誤頁面Spring Boot
- Spring Bean容器SpringBean
- 【Spring】Bean管理SpringBean
- Spring注入bean報錯 Error creating bean with name的網上找不到的解決方案SpringBeanError
- spring 快取 @Cacheable 錯誤總結Spring快取
- Spring bean 裝配SpringBean
- Spring Bean 綜述SpringBean
- Spring Bean作用域SpringBean