`

将hibernate的配置移植到spring中

    博客分类:
  • J2EE
阅读更多
<?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:util="http://www.springframework.org/schema/util"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
	
	 <bean id="propertyConfigurer"  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>/WEB-INF/config/jdbc.properties</value>
            </list>
        </property>
 		</bean>	 
	 <!-- 数据源 -->
	<bean id="dataSource"
		class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName"
			value="${jdbc.driverClassName}" />
		<property name="url"
			value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
		
		<property name="initialSize" value="5" />
		<property name="maxActive" value="100" />
		<property name="maxIdle" value="30" />
		<property name="maxWait" value="1000" />
		<property name="poolPreparedStatements" value="true" />
		<property name="defaultAutoCommit" value="false" />
	</bean>
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"></property>
		<property name="mappingResources">
			<list>
				<value>com/yuanhai/pojo/Admin.hbm.xml</value>
				<value>com/yuanhai/pojo/Contactway.hbm.xml</value>
				<value>com/yuanhai/pojo/Freephne.hbm.xml</value>
				<value>com/yuanhai/pojo/HelpInfo.hbm.xml</value>
				<value>com/yuanhai/pojo/IndexClass.hbm.xml</value>
				<value>com/yuanhai/pojo/Pictures.hbm.xml</value>
				<value>com/yuanhai/pojo/Scheme.hbm.xml</value>
				<value>com/yuanhai/pojo/Subclass.hbm.xml</value>
				<value>com/yuanhai/pojo/SubclassInfo.hbm.xml</value>
				<value>com/yuanhai/pojo/SuclssInfoContent.hbm.xml</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.format_sql">true</prop>
			</props>
		</property>
	</bean>
	<!-- 数据库访问的基类 -->
	<bean id="baseDao" class="com.yuanhai.utils.BaseDao">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
	<!-- 事务相关配置 -->
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
	<tx:advice id="adv" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="add*" propagation="REQUIRED" />
			<tx:method name="remove*" propagation="REQUIRED" />
			<tx:method name="modif*" propagation="REQUIRED" />
			<tx:method name="*" propagation="SUPPORTS" read-only="true" />
		</tx:attributes>
	</tx:advice>
	<aop:config>
		<aop:advisor advice-ref="adv"
			pointcut="execution(public * com.yuanhai.biz.*.*(..))" />
	</aop:config>
	<!-- 其它资源文件引入-->
	<import resource="config/spring/system.xml" />
</beans>


网上全面文章
http://blog.csdn.net/ayan117/archive/2010/07/20/5748134.aspx

分享到:
评论

相关推荐

    springboot(4) 整合mybatis和hibernate

    springboot(4) 整合mybatis和hibernate 请删除项目中本地仓库的配置,或者改成国内的公共仓库,否则将无法启动

    通用后台管理系统(ExtJS 4.2+Hibernate 4.1.7+Spring MVC 3.2.8)

    5、数据库是MySQL、Oracle和SQL Server,Hibernate的Dialect可使程序移植到其他数据库。 6、采用开源的互动地图Javascript库Leaflet,处理自定义在线地图。 7、采用Google Guava Collections,性能高于Apache ...

    ssh(structs,spring,hibernate)框架中的上传下载

     代码 4 Spring中有关Hibernate的配置信息 1. 2. !-- 数据源的配置 //--> 3. 4. destroy-method="close"> 5. 6. 7. 8. 9. 10. !-- Hibernate会话工厂配置 //--> 11. 12. class="org.springframework.orm...

    Struts2+Hibernate+Spring框架电子商城

    本系统采用的关键技术是Struts2+...Spring是以MVC模式为基础,依赖注入为核心的Java应用框架,它利用Java的反射机制,将系统各层无缝的整合在一起,实现了系统各模块和各层次的解藕,提高了系统的可维护性和可移植性。

    最新JAVA通用后台管理系统(ExtJS 4.2+Hibernate 4.1.7+Spring MVC 3.2.8)Eclipse版本

    5、数据库是MySQL、Oracle和SQL Server,Hibernate的Dialect可使程序移植到其他数据库。 6、采用开源的互动地图Javascript库Leaflet,处理自定义在线地图。 7、采用Google Guava Collections,性能高于Apache ...

    Spring-Reference_zh_CN(Spring中文参考手册)

    6.8.1. 在Spring中使用AspectJ来为domain object进行依赖注入 6.8.1.1. @Configurable object的单元测试 6.8.1.2. 多application context情况下的处理 6.8.2. Spring中其他的AspectJ切面 6.8.3. 使用Spring IoC来...

    Spring中文帮助文档

    6.8.1. 在Spring中使用AspectJ进行domain object的依赖注入 6.8.2. Spring中其他的AspectJ切面 6.8.3. 使用Spring IoC来配置AspectJ的切面 6.8.4. 在Spring应用中使用AspectJ加载时织入(LTW) 6.9. 更多资源 7...

    ExtJS 4.2+JAVA通用后台管理系统(ExtJS 4.2+Hibernate 4.1.7+Spring MVC 3.2.8)

    5、数据库是MySQL、Oracle和SQL Server,Hibernate的Dialect可使程序移植到其他数据库。 6、采用开源的互动地图Javascript库Leaflet,处理自定义在线地图。 7、采用Google Guava Collections,性能高于Apache ...

    最新JAVA通用后台管理系统(ExtJS 4.2+Hibernate 4.1.7+Spring MVC 3.2.8)MyEclipse版本

    5、数据库是MySQL、Oracle和SQL Server,Hibernate的Dialect可使程序移植到其他数据库。 6、采用开源的互动地图Javascript库Leaflet,处理自定义在线地图。 7、采用Google Guava Collections,性能高于Apache ...

    spring2.0技术手册 (扫描版)

    第1章认识Spring ...Spring Framework 是一个开源的Java/Java EE全功能栈(full-stack)的应用程序框架,以Apache许可证形式发布,也有.NET平台上的移植版本 喜欢Java web开发的童鞋可以上手Spring MVC

    Spring 2.0 开发参考手册

    6.8.1. 在Spring中使用AspectJ来为domain object进行依赖注入 6.8.2. Spring中其他的AspectJ切面 6.8.3. 使用Spring IoC来配置AspectJ的切面 6.8.4. 在Spring应用中使用AspectJ Load-time weaving(LTW) 6.9. ...

    Spring基础与快速入门

    4 依赖注入:建立对象与对象之间依赖关系的实现,包括接口注入、构造注入、set注入,在Spring中只支持后两种 5 AOP:面向方面编程,我们可以把日志、安全、事务管理等服务(或功能)理解成一个“方面”,那么以前...

    extShop(Struts2+Hibernate+Spring+ExtJs)

    后来我把代码移植到自己的SSH项目上,才运行起来,稍微修改一点代码。前台用Extjs,数据库也在里面,其实不需要数据库的,hibernate可以自动生成,前提先建好数据库。主要用来学习ExtJs还不错,ExtJs用起来感觉和...

    Hibernate使用技巧汇总

    HibernateTemplate对Hibernate Session操作进行了封装,而 HibernateTemplate.execute方法则是一封装机制的核心 *在spring的配置文件里,移植了整个hibernate.cfg.xml的内容。

    Spring API

    6.8.1. 在Spring中使用AspectJ进行domain object的依赖注入 6.8.2. Spring中其他的AspectJ切面 6.8.3. 使用Spring IoC来配置AspectJ的切面 6.8.4. 在Spring应用中使用AspectJ加载时织入(LTW) 6.9. 更多资源 7...

    spring chm文档

    6.8.1. 在Spring中使用AspectJ来为domain object进行依赖注入 6.8.2. Spring中其他的AspectJ切面 6.8.3. 使用Spring IoC来配置AspectJ的切面 6.8.4. 在Spring应用中使用AspectJ Load-time weaving(LTW) 6.9. ...

    Spring.Net + NHibernate 入门例子

    Spring.Net 是一个很强大的框架,在java里非常的火,NHibernate也是从java里移植过来的.不过和Java下面的用法有所区别.

    spring-hibernate3-2.0.8.jar.zip

    java jar包,亲测试可用 ...把一个JAR文件添加到系统的classpath环境变量之后,java通常会把这个JAR文件当做一个路径来处理。通常使用jar命令来压缩,可以把一个或多个路径全部压缩成一个JAR文件。

    sharts:一个关于Spring,Hibernate,iText,Poi和OpenCSV的简单项目

    [Spring]-帮助开发人员构建基于JVM的简单,可移植,快速和灵活的系统和应用程序 [Hibernate]-一个开源Java持久性框架项目。 [OpenCSV]-Opencsv是一个非常简单的用于Java的csv(逗号分隔值)解析器库。 [POI]-用于...

Global site tag (gtag.js) - Google Analytics