課程
/后端開發(fā)
/Java
/Spring入門篇
這是哪一個知識點,在哪個文件配置的文件參數(shù)呢?看到這里一臉懵逼~~~
2016-04-05
源自:Spring入門篇 2-2
正在回答
我大概明白,我沒有寫那個UnitTestBase 類,也沒有去繼承它。。。
所以super父類的構造方法肯定會報錯。。。暈菜,去看了下源碼才察覺到那個類是自定 義的測試類。0 - 0
????????private?ApplicationContext?ctx; @Before public?void?init(){ ctx=new??ClassPathXmlApplicationContext("spring-injection.xml"); } @Test public?void?testSetter(){ //ApplicationContext?ctx=new??ClassPathXmlApplicationContext("spring-injection.xml"); InjectionService?service?=?(InjectionService)?ctx.getBean("injectionService"); service.save("為什么會這樣子呢?"); }
這是我根據(jù)helloworld方法改的測試方法,也可以實現(xiàn)。
不過就是不懂 super("XML文件") 為什么行不通。。
package?com.imooc.test.ioc.injection; import?org.junit.Test; import?org.junit.runner.RunWith; import?org.junit.runners.BlockJUnit4ClassRunner; import?com.imooc.ioc.injection.service.InjectionService; @RunWith(BlockJUnit4ClassRunner.class) public?class?TestInjection?{ public?TestInjection(){ super("spring-injection.xml"); } @Test public?void?testSetter(){ //InjectionService?service?=?super } }
super那個出錯了提示The constructor Object(String) is undefined
下面是我的項目結構,用的是myeclipse?
沒弄懂為什么super()出現(xiàn)什么問題,我上網去看一些helloworld可以用下面這方法讀取解析xml文件。
ApplicationContext ctx=new ?ClassPathXmlApplicationContext("applicationcontext.xml");
HelloWorld helloworld=(HelloWorld)ctx.getBean("helloworld");
那個名字? 叫
spring-injection.xml
其實這個就行web.xml一樣的?? 懂沒? 只是名字變了而已
輝揚 提問者
舉報
為您帶來IOC和AOP的基本概念及用法,為后續(xù)高級課程學習打下基礎
3 回答super("classpath*:spring-injection.xml");
2 回答spring-injection.xml位置問題
1 回答spring-injection.xml放在哪里,UnitTestBase是如何找到它的?
1 回答這里不太懂, 前面講得xml配置 和后面的實例不是一個啊 ?
1 回答聽不懂了啊
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-04-06
我大概明白,我沒有寫那個UnitTestBase 類,也沒有去繼承它。。。
所以super父類的構造方法肯定會報錯。。。暈菜,去看了下源碼才察覺到那個類是自定 義的測試類。0 - 0
2016-04-06
這是我根據(jù)helloworld方法改的測試方法,也可以實現(xiàn)。
不過就是不懂 super("XML文件") 為什么行不通。。
2016-04-06
super那個出錯了提示The constructor Object(String) is undefined
下面是我的項目結構,用的是myeclipse?
沒弄懂為什么super()出現(xiàn)什么問題,我上網去看一些helloworld可以用下面這方法讀取解析xml文件。
ApplicationContext ctx=new ?ClassPathXmlApplicationContext("applicationcontext.xml");
HelloWorld helloworld=(HelloWorld)ctx.getBean("helloworld");
2016-04-05
那個名字? 叫
spring-injection.xml
其實這個就行web.xml一樣的?? 懂沒? 只是名字變了而已