下面是用一个具体例子写的模版(支持annotation的配置),需要时稍微改改就行:
<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.test"/>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/xrovers"></property>
<property name="username" value="root"></property>
<property name="password" value=""></property>
<property name="maxActive" value="10"></property>
<property name="maxIdle" value="30"></property>
<property name="maxWait" value="500"></property>
<property name="defaultAutoCommit" value="true"></property>
</bean>
<!--
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<!--
<property name="mappingResources">
<list>
<value>com/test/bean/User.hbm.xml
</list>
</property>
-->
<property name="annotatedClasses">
<list>
<value>com.test.bean.User</value>
</list>
</property>
</bean>
<!-- 这是action -->
<bean id="" class="" scope="prototype">
<property name="" ref=""></property>
</bean>
</beans>
被注释掉的部分是xxx.hbm.xml配置文件的设置。但是用于annotation的配置同样也可以用与hbm文件配置,因为org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean继承了org.springframework.orm.hibernate3.LocalSessionFactoryBean。
分享到:
相关推荐
a 加入支持:添加 spring核心包、hibernate 3.6 包、 spring整合hibernate包 , 在src下建立applicationContext.xml (先建立src下便于测试hibernate)。 b 编写实体类,加入hibernate注解,编写方法类测试类,在...
第24次课-1 Spring与Hibernate的整合 本节主要内容 24.1 概述 24.2 管理SessionFactory 24.3 Spring对Hibernate的简化 24.1 概述 24.1.1 概述 Spring提供了很多IoC特性的支持,方便处理大部分典型的Hibernate整合...
ssh spring+hibernate+struts 开发模板 验证框架
SSH(struts+spring+hibernate)框架 ,写好的模板,可直接填写代码,也可以用来学习,jar包齐全
制作好的SSH框架模板,可以直接导入MyEclipse使用,已经自动所有jar包
三个框架整合的实例程序,其中是eclipse的项目,大家只要导入就可以啦,可以当作一个模版来搭建自己的开发环境。
struts2.0+spring2.5+hibernate3.0整合框架,下载导入到eclipse下即可。。启动tomcat前先修改jdbc.properties文件。由于lib文件较大,所以请自行导入相关lib包。
spring管理组件,springmvc分层,springaop配置数据库事务控制,hibernate二级缓存配置,实现了查询,用户登录注册,请求验证是否登录等基础功能Demo,基于后台测试,使用前台模板修改url路径即可。
spring+springMVC+hibernate+maven+tomcat7整合,myEclipse项目(完整html页面模板)
基于ssh2的员工信息管理项目。运行完美可用,可以当作整合好的环境使用,也可以将项目少做修改当作课程设计所用,反正此项目已完美解决了很多整合中遇到的问题。...spring4 hibernate4.2 struts2.3.15
图文教程MyEclipse配置struts...本文档最后部分是一个实战演习,讲述如何使用struts、hibernate和spring三个框架来实现一个完整的Web应用程序,包括建立数据库连接、生成FreeMarker模板、配置struts-config.xml文件等。
struts2.1.8+spring2.5.6+hibernate3.3.2整合项目开发 比较完整哦 可以作为模板的
每次自己搭个环境测试Spring或Hibernate都需要找jar包,看文档,干脆做个模板传上来,方便自己用
全新整合 SSH Struts2+Spring3+Hibernate4 采用Struts2注解 有lib包。一个小实例 完美模版整合.zip 全新整合 SSH Struts2+Spring3+Hibernate4 采用Struts2注解 有lib包。一个小实例 完美模版整合.zip 全新整合 SSH ...
该资源中包含SSH框架整合中spring框架所需要的全部jar包。包括: (1)IOC核心包(4个包和2个日志包) (2)整合web (3)Spring整合JUnit测试包 ...(6)Spring整合Hibernate核心包 (7)Spring整合Struts2核心包
spring管理组件,springmvc分层,springaop配置数据库事务控制,hibernate二级缓存配置,实现了查询,用户登录注册,请求验证是否登录等基础功能Demo,基于后台测试,使用前台模板修改url路径即可。
spring3,struts2,hibernate3整合模版,各种配置文件你懂得
本系统采用SpringMVC+Hibernate+Spring框架整合开发,数据库使用MySQL,构建工具是Gradle。其中前台页面使用了Bootstrap中的一个模板AdminLTE进行美化,可导入IntelliJ IDEA使用。 参考了多个OA相关的项目,大概实现...
Struts spring hibernate整合框架模板,附带了一个示例demo,可以直接运行
这个是strtus2 spring hibernate 整合的模板,不需要每次新项目都考虑整合了。还不错.提高效率