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;
    //    }
    }
  • 相关阅读:
    poj 2689 大范围内素数筛选
    poj 3270 置换
    Linux命令(实时更新)
    性能测试
    sql注入
    MySQL回表查询
    MySQL数据库高可用方案
    java反射机制
    分布式数据库
    数据库的灾备
  • 原文地址:https://www.cnblogs.com/chencn/p/12341221.html
Copyright © 2011-2022 走看看