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;
    //    }
    }
  • 相关阅读:
    APP开发的模式
    微信小程序的传值方式
    面试题总结
    github上传文件的步骤
    python使用笔记15--操作Excel
    python使用笔记14--商品管理小练习
    python使用笔记13--清理日志小练习
    python使用笔记12--操作mysql数据库
    python使用笔记11--时间模块
    python使用笔记10--os,sy模块
  • 原文地址:https://www.cnblogs.com/chencn/p/12341221.html
Copyright © 2011-2022 走看看