问答详情
源自:4-8 DAO层单元测试编码和问题排查(上)

Run As Junit Test 出错

http://img.mukewang.com/589d6f97000160bc14070740.jpg


http://img.mukewang.com/589d77650001d01f11360223.jpg


大神帮忙看看,哪里错啦???啥问题,怎么解决???

提问者:四叶草旳眼泪3386375 2017-02-10 15:46

个回答

  • 四叶草旳眼泪3386375
    2017-02-14 08:54:38

    <?xml version="1.0" encoding="UTF-8"?>

    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

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

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

    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">


    <context:property-placeholder location="classpath:jdbc.properties" />

    <!-- 2:数据库连接池 -->

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">

    <!-- 配置连接池属性 -->

    <property name="driverClass" value="${driver}" />

    <property name="jdbcUrl" value="${url}" />

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

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

    <!-- c3po连接池的私有属性 -->

    <property name="maxPoolSize" value="30" />

    <property name="minPoolSize" value="10" />

    <!-- 关闭连接后不自动commit -->

    <property name="autoCommitOnClose" value="false" />

    <!-- 获取连接超时时间 -->

    <property name="checkoutTimeout" value="20000" />

    <!-- 获取连接失败重试次数 -->

    <property name="acquireRetryAttempts" value="3" />

    </bean>


    <!-- 3:配置sqlSessionFactory对象 -->

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

    <!-- 注入数据库连接池 -->

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

    <!-- 配置myBatis全局配置文件:mybatis-config.xml -->

    <property name="configLocation" value="classpath:mybatis-config.xml" />

    <!-- 扫描entity包 使用别名 -->

    <property name="typeAliasesPackage" value="org.seckil.entity" />

    <!-- 扫描sql配置文件:mapper需要的xml文件 -->

    <property name="mapperLocations" value="classpath:mapper/*.xml" />

    </bean>


    <!-- 4:配置扫描dao接口包,动态实现dao接口,注入到spring容器中 -->

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

    <!-- 注入sqlSessionFactory -->

    <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />

    <!-- 给出需要扫描的dao接口包 -->

    <property name="basePackage" value="org.seckil.dao" />

    </bean>

    </beans>


  • Nesive
    2017-02-13 20:20:19

    给我看下你的spring-dao.xml

  • 四叶草旳眼泪3386375
    2017-02-13 09:11:04

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/spring-dao.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\ECODE\seckill\target\classes\mapper\SuccessKilledDao.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'SuccessKilled'.  Cause: java.lang.ClassNotFoundException: Cannot find class: SuccessKilled

  • 疾风阿多
    2017-02-11 16:24:06

    错误在第一张图片的下面,没有截屏完整