applicationContext-mybatis.xml 把这个文件贴上来!

解决方案 »

  1.   

    应该是没有引  mybatis-spring.jar 包
      

  2.   

    <!-- JNDI获取数据源(使用c3p0连接池) -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close" dependency-check="none">
    <property name="driverClass" value="${jdbc.driverClassName}" />
    <property name="jdbcUrl" value="${jdbc.url}" />
    <property name="user" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="autoCommitOnClose" value="true" />
    <property name="checkoutTimeout" value="${cpool.checkoutTimeout}" />
    <property name="initialPoolSize" value="${cpool.minPoolSize}" />
    <property name="minPoolSize" value="${cpool.minPoolSize}" />
    <property name="maxPoolSize" value="${cpool.maxPoolSize}" />
    <property name="maxIdleTime" value="${cpool.maxIdleTime}" />
    <property name="acquireIncrement" value="${cpool.acquireIncrement}" />
    <property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}" />
    </bean>
    <!--
    (事务管理)transaction manager, use JtaTransactionManager for global tx
    -->
    <bean id="transactionManager"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
    </bean> <!--
    (Annotation方式配置services)enable component scanning (beware that this
    does not enable mapper scanning!)
    -->
    <context:component-scan base-package="com.xxx.service" /> <!-- enable autowire -->
    <context:annotation-config /> <!-- enable transaction demarcation with annotations -->
    <tx:annotation-driven /> <!--
    define the SqlSessionFactory, notice that configLocation is not needed
    when you use MapperFactoryBean
    -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="configLocation" value="classpath:mybatis-config.xml" />
    <property name="mapperLocations">
    <list>
    <value>classpath*:com/xxx/dao/*.xml</value>
    </list>
    </property>
    </bean> <!-- scan for mappers and let them be autowired -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <!-- Mapper接口所在包名,Spring会自动查找其下的Mapper -->
    <property name="basePackage" value="com.xxx.dao" />
    </bean>