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>  

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

2个回答

ak46143279
脸不大 已经解决了,谢谢你
3 年多之前 回复

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!