亚洲免费在线视频-亚洲啊v-久久免费精品视频-国产精品va-看片地址-成人在线视频网

您的位置:首頁技術(shù)文章
文章詳情頁

java - SSH整合時(shí) getHibernateTemplate()為空

瀏覽:125日期: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及其子包下面自動(dòng)掃描通過注解配置的組件 --> <context:component-scan base-package='com.lcy' /> <!-- 激活自動(dòng)代理功能,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 已經(jīng)幫你把 basedao 注入了你XML里配置好的對(duì)象, 你后面又用

basedao = new BaseDAO();

創(chuàng)建了個(gè)新對(duì)象, 把那個(gè) Spring 給注入的 bean 替換掉了...

標(biāo)簽: java
相關(guān)文章:
主站蜘蛛池模板: 国产在线不卡视频 | 九色福利 | 日韩免费专区 | 国产精品久久久久久久久久98 | 播放一级毛片 | 最新国产精品视频免费看 | 国产a久久精品一区二区三区 | 国产精品理论片 | 日韩精品一区二区三区免费视频 | 国产午夜精品久久久久免费视 | 亚洲第一区视频在线观看 | 人成午夜 | 透逼视频 | 国内精品久久久久影院免费 | 国产精品路边足疗店按摩 | 久久久不卡国产精品一区二区 | 97精品国产福利一区二区三区 | 日本红怡院亚洲红怡院最新 | 99精彩视频 | 欧美一级爱操视频 | 亚洲综合色视频在线观看 | 亚洲国产精品线在线观看 | 国产精品视频一区二区猎奇 | 亚洲精品久久久久综合中文字幕 | 大陆孕妇孕交视频自拍 | 亚洲一区在线观看视频 | 亚洲视频免费在线看 | 国产全部理论片线观看 | 国内精品久久影院 | 国产精品爱久久久久久久三级 | 国产网友自拍 | 日韩久操 | 成年人网站黄 | 亚洲美女黄色片 | 一级毛片免费观看久 | 性色tv视频观看 | 精品在线观看国产 | 欧美在线视频一区二区 | 精品久久看 | 伊人久久大香线焦综合四虎 | 亚洲永久中文字幕在线 |