spring+ibatis整合错误问题,谁帮我看看问题在哪?错误提示: No SqlMapClient specified

解决方案 »

  1.   

    dao 的初始化问题
    应该用spring框架来初始化 
      

  2.   

    这个怎么初始化呢。比如 public class TestSI extends SqlMapClientDaoSupport {

       public List getProduct(String productId) throws DataAccessException {
      // List list = this.getSqlMapClientTemplate().queryForList("selectAllStudent");
       Student student = (Student) getSqlMapClientTemplate().queryForObject("Student.selectbyid",1);
    //    for(int i = 0 ; i < list.size() ; i ++){
    //    System.out.println();
    //    }
         return null;
       }
       public static void main(String[] args){
       TestSI dao = new TestSI();
       dao.getProduct("1");
       }
       
     }
    这个方法如何修改,谢谢
      

  3.   

    应该初始化sqlmapclient,比如在main中自己建立一个sqlMapClient=new org.springframework.orm.ibatis.SqlMapClientFactoryBean();
    这里还需要配置一下datasource的
      

  4.   

    可以在main中初始化sqlmapclient = new org.springframework.orm.ibatis.SqlMapClientFactoryBean()
    同时还要配置datasource希望对你有帮助
      

  5.   

    LZ你在使用getSqlMapClientTemplate()之前,必须先装载org.springframework.orm.ibatis.SqlMapClientFactoryBean;并且在SqlMapClientFactoryBean中指定数据源和查询语句sql文件。
    我给你一个例子:
    <bean id="sqlMapClient" 
            class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
            <property name="configLocations">
                <list>
                    <value>classpath:_ibatis/SqlMapConfig.xml</value>                
                </list> 
            </property>
            <property name="dataSource">
                <ref bean="dataSource"/>
            </property>    
        </bean>  
      

  6.   

    我正在使用ssi框架,这个样子写没错!