ibatis利用spring对其支持配置

  <bean id="sqlMapClient"
        class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    <property name="configLocation">
      <value>/WEB-INF/sql-map-config.xml</value>
    </property>
     <property name="dataSource">
      <ref bean="dataSource.FBCM" />
    </property>  
  </bean>
  <bean id="baseDao"
        class="com.nstc.fbth.dao.BaseDao">
    <property name="sqlMapClient">
      <ref local="sqlMapClient" />
    </property>        
  </bean>

 上述是spring配置文件

 下面是basedao类

 

import javax.sql.DataSource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ibatis.sqlmap.client.SqlMapClient;

public class BaseDao extends SqlMapClientDaoSupport{

    
}

 

其他类如何使用这个basedao呢?applicationContext.xml配置如下。

<bean  id="hrDao"  class="com.nstc.HRInterface.dao.HRInterfaceDao" parent="baseDao"></bean>

 

你可能感兴趣的:(spring)