0 0

最新的spring4怎么跟mybatis集成?5

如题,我没有找到org.springframework.orm.ibatis.SqlMapClientFactoryBean这个类,请教,不胜感激!
2014年12月22日 16:15

3个答案 按时间排序 按投票排序

0 0

需要用到mybatis-spring,这样dao层可以只定义接口,省掉实现类。你可能看看我的一个小项目:https://github.com/OuYangLiang/newffms

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">
        
    <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>
            </list>
        </property>
    </bean>

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName">
            <value>${jdbc.driverClass}</value>
        </property>
        <property name="url">
            <value>${jdbc.url}</value>
        </property>
        <property name="username">
            <value>${jdbc.username}</value>
        </property>
        <property name="password">
            <value>${jdbc.password}</value>
        </property>
        <property name="maxActive">
            <value>${jdbc.maxActive}</value>
        </property>
        <property name="initialSize">
            <value>${jdbc.initialSize}</value>
        </property>
        <property name="maxWait">
            <value>${jdbc.maxWait}</value>
        </property>
        <property name="removeAbandoned">
            <value>true</value>
        </property>
        <property name="removeAbandonedTimeout">
            <value>60</value>
        </property>
        <property name="logAbandoned">
            <value>true</value>
        </property>
        <property name="testOnBorrow">
            <value>true</value>
        </property>
        <property name="validationQuery">
            <value>SELECT 1</value>
        </property>
    </bean>

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.personal.oyl.newffms.dao" />
    </bean>
    
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="mapperLocations" value="classpath*:sqlMap/*.xml" />
    </bean>
    
</beans>

2014年12月22日 22:10
0 0

需要mybatis-spring jar吧

2014年12月22日 21:02
0 0

springside 没有demo吗

2014年12月22日 19:03

相关推荐

Global site tag (gtag.js) - Google Analytics