spring中加入hibernate配置文件
2013-04-25 20:48
423 查看
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 加载外部的jdbc配置文件信息 -->
<bean id ="mappings" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath*:jdbc.properties"></property>
</bean>
<!-- Spring Datasource配置 -->
<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="maxActive" value="100" />
<property name="maxIdle" value="30" />
<property name="maxWait" value="5000" />
<property name="defaultAutoCommit" value="true" />
</bean>
<!-- 设定hibernate的sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="datasource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<!-- 配置映射文件 -->
<property name="configLocations">
<array>
<value>classpath*:cn/right.hbm.xml</value>
</array>
</property>
<!-- 以下是物供实体映射的配置文件 -->
<property name="mappingLocations">
<list>
<value>classpath:/cn/entity/*.hbm.xml</value>
</list>
</property>
</bean>
<!-- hibernate Template 配置-->
<bean id="hibernatetemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 加载权限Spring配置文件 -->
<import resource="classpath*:cn/right-Spring.xml" />
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 加载外部的jdbc配置文件信息 -->
<bean id ="mappings" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath*:jdbc.properties"></property>
</bean>
<!-- Spring Datasource配置 -->
<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="maxActive" value="100" />
<property name="maxIdle" value="30" />
<property name="maxWait" value="5000" />
<property name="defaultAutoCommit" value="true" />
</bean>
<!-- 设定hibernate的sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="datasource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<!-- 配置映射文件 -->
<property name="configLocations">
<array>
<value>classpath*:cn/right.hbm.xml</value>
</array>
</property>
<!-- 以下是物供实体映射的配置文件 -->
<property name="mappingLocations">
<list>
<value>classpath:/cn/entity/*.hbm.xml</value>
</list>
</property>
</bean>
<!-- hibernate Template 配置-->
<bean id="hibernatetemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 加载权限Spring配置文件 -->
<import resource="classpath*:cn/right-Spring.xml" />
</beans>
相关文章推荐
- 跟我一起学extjs5(27--服务端web,spring,hibernate配置文件的加入)
- hibernate+spring配置文件
- Struts2.1&Hibernate3.2&Spring2.5集成[基于Annotation]--配置文件
- spring+hibernate 两种整合方式配置文件的方法
- spring配置文件中添加hibernate属性---如:show_sql;format_sql
- xfire+spring+hibernate 配置文件
- Spring beans——SSH (Spring+Struts+Hibernate)框架搭建之配置文件序列三
- Hibernate hbm——SSH (Spring+Struts+Hibernate)框架搭建之配置文件序列五
- spring 配置hibernate映射文件的两种方法
- Spring3.0、Hibernate3.0、Struts2整合文件配置
- JPA+Spring+druid+hibernate+maven+resetlet 配置文件
- Spring中自动加载Hibernate配置文件
- Spring中的packagesToScan的方式配置hibernate的class文件映射规则的理解
- Spring+Hibernate配置文件-applicationContext.xml设置
- spring+springMVC+Hibernate全注解XML配置文件
- SSH:SSH(Struts1 + Spring + hibernate)整合之配置文件
- Spring配置文件中SessionFactory引用Hibernate配置产生问题的思考
- Spring的mappingDirectoryLocations配置Hibernate映射文件
- Springmvc+Hibernate+mySql 配置文件
- spring配置hibernate映射文件