mybatis-spring 配置实例总报NoClassDefFoundError: SqlSessionFactory异常,请高手指教 applicationContext-mybatis.xml 把这个文件贴上来! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 应该是没有引 mybatis-spring.jar 包 <!-- 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> SSH如何启动服务时检测数据库是否存在!!!!! 数组的下标越界问题 ireport+jasperreport 问题。常做报表的进来给咱解答下! 何去何从 identifier of an instance of was altered from to null JBoss中如何部署EJB? javac可以编译文件可是java却执行不了? 紧急求助;数字和大写数字的转换问题,各位大哥帮忙。 如何配置数据源以和数据库连接? 我安装了JB7想搞J2EE还需要要下载J2EE吗,知道的不回答是小狗 求开发者突击Java Web主流框架整合开发一书的源码 关于sastruts框架的知识
<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>