zoukankan      html  css  js  c++  java
  • Spring-----Mybatis-通过Sqlsessionsupport

    org.springframework.context.support.AbstractApplicationContext refresh
    警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userdaoimpl' defined in class path resource [applicationcontext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userdaoimpl' defined in class path resource [applicationcontext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    1.

    <bean id="userdaoimpl" class="com.sun.dao.UserDaoImpl" >
            <property name="sqlSessionFactory" ref="sqlsessionfactorybean"/>  //继承的抽象类传入的参数(注入)在子类中注入。
     <!-- <property name="sessionTemplate" ref="sqlsession"/>--> </bean>
    public class UserDaoImpl  extends SqlSessionDaoSupport implements UserDao  {
    
    //    private SqlSessionTemplate sessionTemplate;
        @Override
        public List<User> getUserList() {
    //        List<User> userList = sessionTemplate.selectList("com.sun.dao.UserDao.getUserList");
            UserDao mapper = getSqlSession().getMapper(UserDao.class);            //SqlsessionTemplate   ===getSqlSession()
            List<User> userList = mapper.getUserList();
    
            return userList;
        }
    
    //    public void setSessionTemplate(SqlSessionTemplate sessionTemplate) {
    //        this.sessionTemplate=sessionTemplate;
    //    }
    }
  • 相关阅读:
    eclipse中统计代码行数
    vmware ubuntu 最近遇到的一些问题
    Shows how to create and run composites dynamically
    程序员的艺术:排序算法舞蹈
    Apache Mina 网络通信
    OutOfMemoryError汇总
    c++/java/c# 几种编程语言的指针、引用比较
    Silverlight开发工具集合
    web.cong 详解
    ASP.NET中的web.config配置
  • 原文地址:https://www.cnblogs.com/chencn/p/12341221.html
Copyright © 2011-2022 走看看