天天看點

Spring內建ibatis ,applicationContext.xml裡的配置

<?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資料庫