亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

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

java - SSH整合時 getHibernateTemplate()為空

瀏覽:93日期: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
相關文章:
主站蜘蛛池模板: 久久国产乱子伦精品在 | 天天狠狠色综合图片区 | 欧洲最暴性xxxⅹ | 男女爱爱免费 | 亚洲已满18点击进入在线观看 | 51精品视频免费国产专区 | 色天天久久 | 最新在线观看精品国产福利片 | 亚洲在线免费观看视频 | 久久亚洲人成国产精品 | 成年人免费影院 | 台湾亚洲精品一区二区tv | 一级黄色淫片 | 91亚洲国产成人久久精品网站 | 久久青青草原精品国产麻豆 | 日韩在线视精品在亚洲 | 亚洲国产精品欧美综合 | 欧美成人三级一区二区在线观看 | 一级黄视频 | 国产制服丝袜在线观看 | 亚洲黄色在线网站 | 亚洲综合网址 | 爱爱小视频免费体验区在线观看 | 黄黄网站 | 女色在线观看免费视频 | 欧美大黄视频 | 操日本人 | 国产美女久久久 | 91亚洲国产在人线播放午夜 | 国产一级精品毛片 | 一级做性色a爱片久久片 | 国产一级大片免费看 | 亚洲免费福利 | 国产香蕉91tv永久在线 | 奇米影视久久777中文字幕 | 精品视频一区二区三区在线播放 | 欧美日韩在线视频不卡一区二区三区 | 黄色网址中文字幕 | 色婷婷影院在线视频免费播放 | 国产淫视频 | 免费黄色片大全 |