Run As Junit Test 出错

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

四叶草旳眼泪3386375

2017-02-10 15:46

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


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


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

写回答 关注

4回答

  • 四叶草旳眼泪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-14 14:17:15

    共 3 条回复 >

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

    给我看下你的spring-dao.xml

    四叶草旳眼泪...

    大哥,你看看,在下面,xml错啦吗?

    2017-02-14 08:55:36

    共 1 条回复 >

  • 四叶草旳眼泪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

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

    四叶草旳眼泪...

    哥们,我给你复制啦,你看看怎么解决,啥情况啊???

    2017-02-13 09:10:31

    共 1 条回复 >

Java高并发秒杀API之业务分析与DAO层

Java实现高并发秒杀API的第一门课,还等什么,赶快来加入吧

87424 学习 · 496 问题

查看课程

相似问题