色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術文章
文章詳情頁

java - SSH整合時 getHibernateTemplate()為空

瀏覽:98日期:2023-11-05 16:39:37

問題描述

@Repositorypublic class AuthorAdminDaoImpl implements IAuthorAdminDao { @Resource private BaseDAO basedao;public boolean loginAuthorAdmin(AuthorAdmin aa) {try { String queryString = ' from AuthorAdmin a where a.authorName= ? and a.authorPwd= ? '; basedao=new BaseDAO(); if (basedao.getTemplate() == null) {System.out.println('沒有獲得HibernateTemplate?'); } List<AuthorAdmin> find = (List<AuthorAdmin>) basedao.getTemplate().find( queryString, aa.getAuthorUsername(), aa.getAuthorPwd()); if (find != null && find.size() > 0) {return true; } else {return false; }} catch (Exception e) { e.printStackTrace(); throw new RuntimeException();}} }

public class BaseDAO extends HibernateDaoSupport{ public HibernateTemplate getTemplate(){return getHibernateTemplate(); }}

HibernateTemplate為空不知道為什么?用的是Spring注入

<?xml version='1.0' encoding='UTF-8'?><beans xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.springframework.org/schema/beans' xmlns:context='http://www.springframework.org/schema/context'xmlns:aop='http://www.springframework.org/schema/aop'xsi:schemaLocation='http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.1.xsd'><!-- 激活組件掃描功能,在包gk.aop及其子包下面自動掃描通過注解配置的組件 --> <context:component-scan base-package='com.lcy' /> <!-- 激活自動代理功能,false或者省略基于接口的代理,為true基于類的的代理 --> <aop:aspectj-autoproxy proxy-target- /> <bean class='org.apache.commons.dbcp.BasicDataSource'><property name='driverClassName' value='com.mysql.jdbc.Driver'></property><property name='url' value='jdbc:mysql://localhost:3306/ssh'></property><property name='username' value='root'></property><property name='password' value='root'></property> </bean> <bean class='org.springframework.orm.hibernate3.LocalSessionFactoryBean'><property name='dataSource'> <ref bean='dataSource' /></property><property name='hibernateProperties'> <props><prop key='hibernate.dialect'> org.hibernate.dialect.MySQLDialect</prop><prop key='hibernate.format_sql'> true</prop><prop key='hibernate.show_sql'> true</prop> </props></property><property name='mappingResources'> <list><value>com/lcy/po/DocumentInfo.hbm.xml</value><value>com/lcy/po/ColumnEditorAdmin.hbm.xml</value><value>com/lcy/po/ExpertAdmin.hbm.xml</value><value>com/lcy/po/AttachInfo.hbm.xml</value><value>com/lcy/po/DocumentStateInfo.hbm.xml</value><value>com/lcy/po/ColumnInfo.hbm.xml</value><value>com/lcy/po/MessageInfo.hbm.xml</value><value>com/lcy/po/MagazineEditorAdmin.hbm.xml</value><value>com/lcy/po/BoardInfo.hbm.xml</value><value>com/lcy/po/ExpertAssess.hbm.xml</value><value>com/lcy/po/AuthorAdmin.hbm.xml</value> </list></property> </bean> <bean class='com.lcy.dao.BaseDAO'><property name='sessionFactory'> <ref bean='sessionFactory'></ref></property> </bean></beans>

問題解答

回答1:

本來 Spring 已經幫你把 basedao 注入了你XML里配置好的對象, 你后面又用

basedao = new BaseDAO();

創建了個新對象, 把那個 Spring 給注入的 bean 替換掉了...

標簽: java
相關文章:
主站蜘蛛池模板: 中文字幕亚洲综合久久男男 | 久操免费在线 | 久久手机在线视频 | 国产va免费精品高清在线观看 | 亚洲最新视频在线观看 | 久草免费手机视频 | 国产一区二区fc2ppv在线播放 | 一区二区3区免费视频 | 99久免费精品视频在线观看2 | 亚洲男人天堂 | 波多野结衣中文一区二区免费 | 久久精品免费一区二区视 | 我们2018在线完整免费观看 | 日韩色视频一区二区三区亚洲 | 欧美成人午夜免费完成 | 天天五月天丁香婷婷深爱综合 | 亚洲一区二区三区中文字幕 | 91日韩精品天海翼在线观看 | 深夜爽爽爽gif福利免费 | 国产欧美在线播放 | 中文国产成人精品久久久 | 国产三级网站在线观看 | 在线精品播放 | 亚州在线播放 | 亚洲成人黄色在线观看 | 欧美一级特黄刺激爽大片 | 成人国产亚洲欧美成人综合网 | 亚洲91精品 | 九九精品视频一区二区三区 | 亚洲精品一区二区三区在 | 杨幂国产精品福利在线观看 | 极品欧美 | 久久国内精品自在自线400部o | 一级黄色毛片免费看 | 欧美做a一级视频免费观看 欧美做爱毛片 | 成人黄网大全在线观看 | 国产亚洲精品成人婷婷久久小说 | 亚洲天堂视频在线观看免费 | 羞羞一区二区三区四区片 | 久久99亚洲精品久久频 | 午夜久久影院 |