2 ak46143279 ak46143279 于 2016.04.29 15:35 提问

SpringMVC+mybatis运行报错

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [F:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SimulatedMarket\WEB-INF\classes\com\iquant\simulated\mapping\StrategySystemAccountDao.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 'com.iquant.simulated.entity.StrategySystemAccount'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.iquant.simulated.entity.StrategySystemAccount

mybatis配置:
<!-- 自动扫描 -->



<!-- 引入配置文件 -->

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">



    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"  
        destroy-method="close">  
        <property name="driverClassName" value="${datasource.driver}" />  
        <property name="url" value="${datasource.url}" />  
        <property name="username" value="${datasource.username}" />  
        <property name="password" value="${datasource.password}" />  
        <!-- 初始化连接大小 -->  
        <property name="initialSize" value="${datasource.initialSize}"></property>  
        <!-- 连接池最大数量 -->  
        <property name="maxActive" value="${datasource.maxActive}"></property>  
        <!-- 连接池最大空闲 -->  
        <property name="maxIdle" value="${datasource.maxIdle}"></property>  
        <!-- 连接池最小空闲 -->  
        <property name="minIdle" value="${datasource.minIdle}"></property>  
        <!-- 获取连接最大等待时间 -->  
        <property name="maxWait" value="${datasource.maxWait}"></property>  
    </bean>  

    <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->  
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
        <property name="dataSource" ref="dataSource" />  
        <!-- 自动扫描mapping.xml文件 -->  
        <property name="mapperLocations" value="classpath:com/iquant/simulated/mapping/*.xml"></property>  
    </bean>  

    <!-- DAO接口所在包名,Spring会自动查找其下的类 -->  
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
        <property name="basePackage" value="com.iquant.simulated.dao" />  
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>  
    </bean>  

    <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->  
    <bean id="transactionManager"  
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
        <property name="dataSource" ref="dataSource" />  
    </bean>  

        找了一天,实在不知道错哪了,求大神指点一二感激不尽啊!

3个回答

CSDNXIAOD
CSDNXIAOD   2016.04.29 15:42

SpringMVC+MyBatis数据库连接报错
----------------------biu~biu~biu~~~在下问答机器人小D,这是我依靠自己的聪明才智给出的答案,如果不正确,你来咬我啊!

ak46143279
ak46143279 ...
一年多之前 回复
u014427391
u014427391   2016.05.01 00:39
ak46143279
ak46143279 已经解决了,谢谢你
一年多之前 回复
ak46143279
ak46143279   2016.05.03 10:50

已经解决,还是配置的问题

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!