ak46143279
脸不大
采纳率27.3%
2016-04-29 07:35 阅读 1.3k

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条回答 默认 最新

  • u014427391 smileNicky 2016-04-30 16:39
    点赞 评论 复制链接分享
  • ak46143279 脸不大 2016-05-03 02:50

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

    点赞 评论 复制链接分享

相关推荐