Spring集成ibatis ,applicationContext.xml里的配置

来源:互联网 发布:linphone ios源码分析 编辑:程序博客网 时间:2024/06/05 06:59
<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="dataSource"  class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="username" value="root"/>
        <property name="password" value="1234"/>
        <property name="url" value="jdbc:mysql://localhost:3306/orclight"/>
    </bean>
    
    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
        <property name="configLocation">
            <value>SqlMapConfig.xml</value>
        </property>
        <property name="dataSource" ref="dataSource" />
    </bean>
    
    <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
        <property name="sqlMapClient" ref="sqlMapClient"/>

    </bean>

</beans>


备注:连接的数据库是mysql数据库


原创粉丝点击