猿问

Failed to load ApplicationContext 一直报错??

<?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:aop="http://www.springframework.org/schema/aop"

       xmlns:tx="http://www.springframework.org/schema/tx"

       xmlns:context="http://www.springframework.org/schema/context"

    xsi:schemaLocation="

       http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/tx 

http://www.springframework.org/schema/tx/spring-tx.xsd

http://www.springframework.org/schema/aop 

http://www.springframework.org/schema/aop/spring-aop.xsd

http://www.springframework.org/schema/context 

http://www.springframework.org/schema/context/spring-context.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 name="jdbcUrl" value="${jdbc.url}" />

       <property name="user" value="${jdbc.username}" />

       <property name="password" value="${jdbc.password}" />

   </bean>


   <!-- 业务 -->

   <bean id="accountService" class="cn.itcast.spring.Demo.AccountDaoImpl">

       <property name="accountDao" ref="accountDao"></property>

   </bean>

   

   <!-- dao -->

   <bean id="accountDao" class="cn.itcast.spring.Demo.AccountDaoImpl">

       <property name="dataSource" ref="dataSource"></property>

   </bean>

 </beans>



package cn.itcast.spring.Demo;


import javax.annotation.Resource;


import org.junit.Test;

import org.junit.runner.RunWith;


import org.springframework.test.context.ContextConfiguration;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


@RunWith(SpringJUnit4ClassRunner.class)

@ContextConfiguration("classpath:applicationContext.xml")

public class SpringTest {

@Resource(name="accountService")

private AccountService accountService;

@Test

public void test1(){

accountService.transfer("aaa", "bbb", 100d);

}


}







qq_指尖旋律_2
浏览 3213回答 1
1回答

慕圣0830664

 <!-- 业务 -->   <bean id="accountService" class="cn.itcast.spring.Demo.AccountDaoImpl"><!-- dao -->   <bean id="accountDao" class="cn.itcast.spring.Demo.AccountDaoImpl">@Resource(name="accountService")private AccountService accountService;看下这几句有什么问题没?已经很明显了,对象的类型不匹配。
随时随地看视频慕课网APP

相关分类

Java
我要回答