第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

大家?guī)兔聪挛疫@單元測試什么問題呀?加載不到application文件

http://img1.sycdn.imooc.com//57b6f72e00010f0105960443.jpg

@RunWith(SpringJUnit4ClassRunner.class)
public?class?SpringDemo1?{
	//測試業(yè)務(wù)層類
	@Resource(name="accountService")
	private?AccountService?accountService;
	@Test
	public?void?demo1(){
		accountService.transfer("aaa","bbb",200d);
	}
	

}



<?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"
????xmlns:aop="http://www.springframework.org/schema/aop"
????xmlns:tx="http://www.springframework.org/schema/tx"
????xsi:schemaLocation="http://www.springframework.org/schema/beans?
????????http://www.springframework.org/schema/beans/spring-beans.xsd??
????????http://www.springframework.org/schema/context
????????http://www.springframework.org/schema/context/spring-context.xsd
????????http://www.springframework.org/schema/aop?
????????http://www.springframework.org/schema/aop/spring-aop.xsd
????????http://www.springframework.org/schema/tx
????????http://www.springframework.org/schema/tx/spring-tx.xsd">

	<!--?引入外部的屬性文件?-->
	<context:property-placeholder?location="classpath:jdbc.properties"/>
	<!--?配置c3P0連接池?-->
	<bean?id="dataSource"?class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property?name="driverClass"?value="${jdbc.driverClass}"></property>
		<property?name="jdbcUrl"?value="${jdbc.url}"></property>
		<property?name="user"?value="${jdbc.username}"></property>
		<property?name="password"?value="${jdbc.password}"></property>
	</bean>
	
	<!--?配置業(yè)務(wù)層類?-->
	<bean?id="accountService"?class="cn.muke.spring.demo1.AccountServiceImpl">
		<property?name="accountDao"?ref="accountDao"></property>
	</bean>
	<!--?配置DAO類?-->
	<bean?id="accountDao"?class="cn.muke.spring.demo1.AccountDaoImpl">
		<property?name="dataSource"?ref="dataSource"></property>
	</bean>
</beans>



正在回答

4 回答

沒加載配置文件

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

大咪 提問者

不是的啊。。。我代碼往貼上去了。。。我這個代碼寫了。。是和老師的一樣,不過報錯還是有java.lang.IllegalStateException: Failed to load ApplicationContext這句話是報錯信息。。麻煩幫我看下。
2016-08-20 回復(fù) 有任何疑惑可以回復(fù)我~
#2

空城丶Dreams 回復(fù) 大咪 提問者

用注解加載配置文件 @ContextConfiguration({"classpath:applicationContext.xml"}) 或者測試方法里 ApplicationContext ac = new ClassPathXmlApplicationContext("xml配置文件");
2016-08-24 回復(fù) 有任何疑惑可以回復(fù)我~
#3

大咪 提問者

非常感謝
2016-08-25 回復(fù) 有任何疑惑可以回復(fù)我~
查看1條回復(fù)

樓上或許是正確的,jar包和jak版本存在兼容性問題,jdk1.8必須是jar包4以上的版本

0 回復(fù) 有任何疑惑可以回復(fù)我~

看一下你的jdk編譯版本,1.8不兼容,改成1.6就ok了,不是系統(tǒng)的,是項目的!右鍵項目>屬性>compiler改成1.6。如果你開發(fā)用的1.8,這個時候項目會有小紅叉,別管他。要想去掉小紅叉,開發(fā)也用1.6。jdk1.8太多坑了……

1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

大咪 提問者

不是你說的這個意思。。。哈哈哈正解我已經(jīng)采納了。。。
2016-08-25 回復(fù) 有任何疑惑可以回復(fù)我~
#2

連宏偉HW 回復(fù) 大咪 提問者

怎么解決的
2016-12-17 回復(fù) 有任何疑惑可以回復(fù)我~

測試類上需要注解 @ContextConfiguration{"application*.xml"}

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

大咪 提問者

不是的啊。。。我代碼往貼上去了。。。我這個代碼寫了。。是和老師的一樣,不過報錯還是有java.lang.IllegalStateException: Failed to load ApplicationContext這句話是報錯信息。。麻煩幫我看下。
2016-08-20 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

大家?guī)兔聪挛疫@單元測試什么問題呀?加載不到application文件

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號