- 浏览: 428575 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (211)
- 思考》感想 (11)
- 数据库操作 譬如Oracle大叔 (7)
- java,咱们有缘吗 (16)
- delphi,你还好吗 (2)
- SSH,哥三儿好 (31)
- 问题!问题?问题!? (9)
- WITH WORK (1)
- 算法与模式 莫事^_^ (10)
- JSP,可以叫你P兄么 (2)
- 啊,咋科斯╮(╯▽╰)╭ (6)
- 巨人肩上的小石子 (2)
- flash她妹flex (38)
- 项目管理 (10)
- 奥特曼,你弟Android来了 (4)
- 麻辣儿gis (0)
- maven 嘛味儿 (3)
- ws 哇塞 webservice (5)
- Oh,no!!!,NoSql (1)
- QQ他哥也是个企鹅,Linux (6)
- 姓i还是姓my 你都叫batis ibatis (3)
- 我喜欢夏天(春天旁边的那个季节)Springside (1)
- 测试! 测就测吧,没有喝(⊙o⊙) (3)
- 是晕+_+ 是浮云 还是云计算 (4)
- ExtJS 你是flex他哥还是他妹 (10)
- svg 你丫的资料真少 (3)
- 叫屁屁还是叫加加 ⊙﹏⊙ c++ (5)
- 鸟,还是只百灵鸟 BIRT (1)
- 权限管理 有权真好 是吧-_-! (1)
- SSH (2)
- 哥三儿好 (2)
- nginx (1)
- Oh (1)
- no!!! (1)
- NoSql (1)
最新评论
-
mong619226543:
谢谢
No identifier specified for entity -
akka_li:
没看懂啥意思!什么原因导致java.net.SocketExc ...
java.net.SocketException: Connection reset 问题解决方法 -
west_jing:
1L正解,<mvc:annotation-dri ...
<mvc:default-servlet-handler/> 导致 Controller失效 -
u010954806:
tgfhfdhdf
Spring Security 国际化文件 messages_zh_CN.properties 中文解释 -
yenshen:
我也碰到这个问题了,找了一大圈,最终问题解决了:<pre ...
<mvc:default-servlet-handler/> 导致 Controller失效
Spring和Hibernate整合配置有两种方式:
方式一:保留hibernate.cfg.xml,整合Spring
Spring配置文件--->
hibernate配置文件--->
方式二: 把Hibernate的配置整合到Spring的配置文件中
Spring配置文件--->
方式一:保留hibernate.cfg.xml,整合Spring
Spring配置文件--->
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 数据源配置 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql:///test"/> <property name="username" value="root"/> <property name="password" value="root"/> <!-- 连接池启动时的初始值 --> <property name="initialSize" value="1"/> <property name="maxActive" value="200"/> <property name="maxIdle" value="5"/> <property name="minIdle" value="2"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <!-- Hibernate配置信息 --> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> </bean> <!-- 配置事务信息 --> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- 采用注解方式进行事务配置 --> <tx:annotation-driven transaction-manager="txManager"/> <!-- 采用注解注入对象 --> <context:annotation-config/> <bean id="personService" class="com.xx.service.impl.PersonServiceBean"></bean> </beans>
hibernate配置文件--->
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.url">jdbc:mysql:///test</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">root</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.hbm2ddl.auto">update</property> <mapping resource="com/xx/dao/Person.hbm.xml"/> </session-factory> </hibernate-configuration>
方式二: 把Hibernate的配置整合到Spring的配置文件中
Spring配置文件--->
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 数据源配置 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql:///test"/> <property name="username" value="root"/> <property name="password" value="root"/> <!-- 连接池启动时的初始值 --> <property name="initialSize" value="1"/> <property name="maxActive" value="200"/> <property name="maxIdle" value="5"/> <property name="minIdle" value="2"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <!-- hbm.xml文件 --> <property name="mappingResources"> <list> <value>com/xx/dao/Person.hbm.xml</value> </list> </property> <!-- Hibernate配置信息 --> <property name="hibernateProperties"> <value> hibernate.dialect=org.hibernate.dialect.MySQL5Dialect hibernate.hbm2ddl.auto=update hibernate.show_sql=true hibernate.format_sql=false </value> </property> </bean> <!-- 配置事务信息 --> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- 采用注解方式进行事务配置 --> <tx:annotation-driven transaction-manager="txManager"/> <!-- 采用注解注入对象 --> <context:annotation-config/> <bean id="personService" class="com.xx.service.impl.PersonServiceBean"></bean> </beans>
发表评论
-
Spring Security 国际化文件 messages_zh_CN.properties 中文解释
2011-05-04 17:08 7031Spring Security 国际化文件 messages_ ... -
两个Spring Security问题
2011-05-04 17:06 2059两个Spring Security问题 ---------》 ... -
一个spring security 配置列子
2011-05-03 16:48 1219<?xml version="1.0" ... -
spring security与数据库交互实现简单例子
2011-04-19 16:34 1632spring security与数据库交互实现简单例子 最近 ... -
用struts2 验证用户登录demo
2011-01-28 15:38 2153用struts2 验证用户登录de ... -
Struts2.1.8 执行顺序
2011-01-28 15:18 864public class LoginAction extend ... -
Struts2令人纠结的一个问题
2011-01-27 09:47 969我用Struts2加入自定义的library如下图,就报错, ... -
一份spring配置文件
2011-01-13 14:05 939<?xml version="1.0" ... -
Hibernate关系映射总结
2010-10-18 10:35 1242其实这些东东完全可以参考帮助文档;这里只是总结下。 》》》一对 ... -
No identifier specified for entity:XX.xx
2010-10-12 17:25 1645No identifier specified for ent ... -
Annotation对Hibernate中联合主键定义
2010-10-11 13:28 2201public class User { private in ... -
@MappedSuperclass的用法
2010-10-11 10:21 12588@MappedSuperclass的用法 用在实体的继承过程 ... -
公共dao的结构
2010-09-29 16:17 1336-----------》公共dao的结构 -----共用接口 ... -
No identifier specified for entity
2010-09-29 16:07 11959org.hibernate.AnnotationExcepti ... -
SSJ配置模板
2009-09-14 09:06 859web.xml-----> <?xml versi ... -
一个简单的ssh配置模板
2009-09-12 17:08 1683web.xml------> <?xml vers ... -
Struts----学习笔记 用form提交和sturts提交
2009-09-12 17:02 1193struts是这么配置的 <action path= ... -
Spring学习笔记--------AOP操作
2009-09-10 10:29 1034* AOP操作可与通过注解和xml的方式实现; * 有个问题, ... -
Hibernate学习笔记1--------一个简单的应用
2009-08-30 08:26 993工具类---------> /** *用单例模式 ... -
Hibernate学习笔记2--------------------一对多、多对一简单配置
2009-08-30 08:40 972一的一端------------------------> ...
相关推荐
spring整合Hibernate学习笔记.docx spring整合Hibernate学习笔记.docx
SSH整合学习笔记之spring与hibernate整合(二)之c3p0 spring与hibernate整合基于XML方式--c3p0数据库连接池的使用。
Struts+spring+hibernate学习笔记! - Struts原理与实践
【SSH学习笔记】整合spring3-hibernate的小项目(一) 配套资源 需求分析: 1、使用spring注入dataSourse数据源 2、使用BaseDao获取注入SessionFactory并返回Session 3、实现查询所有和按字符串查询的方法 4、...
struts与hibernate集成原理,基础知识补充AOP,编程式事务,声明式事务,spring注入学习笔记
Struts2-Spring-Hibernate整合,和Struts2,Hibernate的学习笔记。密码是kmp3314.
Hibernate: 第一课:第一个hibernate项目 第二课:测试实体对象的生命周期 第三课:hibernate基本映射 第四课:hibernate多对一关联映射 ...................... ...第五课:spring对AOP的只是(采用配置文件的方式)
SSH整合学习笔记之spring与hibernate简单整合的源码---对应我的博客文章 http://blog.csdn.net/wanghantong/article/details/6653482
【SSH学习笔记】整合spring3-hibernate的小项目(二) 配套资源 需求分析: 1、使用spring注入dataSourse数据源 2、使用BaseDao获取注入SessionFactory并返回Session 3、用generic接口及其实现类,实现泛型化的...
我自己在学习过程中做的电子笔记和一些要点的整理,希望发感兴趣的朋友下载,才一分,看在我辛辛苦苦整理的份上,不要嫌要下载分哦!
一、 Spring配置hibernate3的SessionFactory 30 (一) xml形式的SessionFactory 30 (二) annotation注解方式的SessionFactory 30 二、 引入hibernate所需要使用的jar 31 (一) 基本jar 31 (二) 加入annotation功能的...
NULL 博文链接:https://microjava.iteye.com/blog/525981
Struts2_hibernate_spring学习笔记,郑大刘铭皓老师课堂笔记
spring从HelloWorld到ioc,aop,对JDBC,hibernate,struts1,struts2的支持笔记
一、 Spring配置hibernate3的SessionFactory 30 (一) xml形式的SessionFactory 30 (二) annotation注解方式的SessionFactory 30 二、 引入hibernate所需要使用的jar 31 (一) 基本jar 31 (二) 加入annotation功能的...
系统讲解Spring框架和Hibernate框架。适合搞Java Web开发人员及初学者。
Unix 学习笔记 Core Java 学习笔记 Tiger 学习笔记 XML 学习笔记 Oracle 学习笔记 JDBC 学习笔记 Hibernate 学习笔记 HTML&JavaScript 学习笔记 Servlet 学习笔记 JSP 学习笔记 ...Spring 学习笔记
SSH整合学习笔记之struts2+spring+hibernate+c3p0源码
JDK5.0 应用服务器:JBOSS4.0.4GA Spring:2.5 Hibernate:3.1 Struts:1.2 学习心德 作者:姚赪海