課程
/后端開(kāi)發(fā)
/Java
/Spring入門篇
RT 就老是出現(xiàn)找不到bean的樣子
2017-06-22
源自:Spring入門篇 4-1
正在回答
//這個(gè)是java文件 package?com.imooc.beanannotation; import?org.springframework.stereotype.Component; @Component public?class?BeanAnnotation?{ public?void?say(String?word){ System.out.println("BeanAnnotation:"+word); } } //這個(gè)是配置文件 <?xml?version="1.0"?encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans? http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> <context:component-scan?base-package="com.imooc.beanannotation"> </context:component-scan> </beans> //這個(gè)是測(cè)試的文件,,我沒(méi)安裝老師那個(gè)方法,而是直接實(shí)例化 @Test public?void?TestbeanAnnotation()?{ ????????ApplicationContext?alc=new?ClassPathXmlApplicationContext("spring-beanannotation.xml"); BeanAnnotation?bean=(BeanAnnotation)alc.getBean("beanAnnotation"); bean.say("fuck"); }
舉報(bào)
為您帶來(lái)IOC和AOP的基本概念及用法,為后續(xù)高級(jí)課程學(xué)習(xí)打下基礎(chǔ)
6 回答為什么會(huì)一直找不到bean?
3 回答為什么會(huì)找不到bean
3 回答為什么我這 bean 的路徑老是說(shuō)找不到?
2 回答關(guān)于Junit顯示名字找不到
4 回答找不到bean
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-06-22