<?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"
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">
<!-- 1.加载属性文件jdbc.properties -->
<context:property-placeholder location="classpath:jdbc.properties" />
<!-- 2.扫描spring注解并自动注入指定包下的bean -->
<context:component-scan base-package="com.*.*" />
<!-- 3.数据源 -->
<import resource="datasource-c3p0.xml" />
<!--4.配置: Hiberante的SessionFactory -->
<bean name="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${mysql.dialect}
</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<!-- 1.mappingResources:指定classpath下具体映射文件名 -->
<!-- <property name="mappingResources"> </property> -->
<!-- 2.mappingLocations:可以指定任何文件路径,并且可以指定前缀 -->
<!-- 通配符指定,'*'指定一个文件(路径)名,'**'指定多个文件(路径)名 -->
<!-- <property name="mappingLocations"> <value>classpath:com/hibernate/bean/**.xml</value>
</property> -->
<!-- 3.mappingDirectoryLocations:指定映射的文件路径 -->
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/hibernate/bean/</value>
</list>
</property>
</bean>
<!-- 使用Hibernate的注解方式获取SessionFactory -->
<bean id="sessionFactrory2"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect"> ${mysql.dialect} </prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="annotatedPackages">
<value>classpath:com/hibernate/bean/</value>
</property>
</bean>
</beans>
<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"
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">
<!-- 1.加载属性文件jdbc.properties -->
<context:property-placeholder location="classpath:jdbc.properties" />
<!-- 2.扫描spring注解并自动注入指定包下的bean -->
<context:component-scan base-package="com.*.*" />
<!-- 3.数据源 -->
<import resource="datasource-c3p0.xml" />
<!--4.配置: Hiberante的SessionFactory -->
<bean name="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${mysql.dialect}
</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<!-- 1.mappingResources:指定classpath下具体映射文件名 -->
<!-- <property name="mappingResources"> </property> -->
<!-- 2.mappingLocations:可以指定任何文件路径,并且可以指定前缀 -->
<!-- 通配符指定,'*'指定一个文件(路径)名,'**'指定多个文件(路径)名 -->
<!-- <property name="mappingLocations"> <value>classpath:com/hibernate/bean/**.xml</value>
</property> -->
<!-- 3.mappingDirectoryLocations:指定映射的文件路径 -->
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/hibernate/bean/</value>
</list>
</property>
</bean>
<!-- 使用Hibernate的注解方式获取SessionFactory -->
<bean id="sessionFactrory2"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect"> ${mysql.dialect} </prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="annotatedPackages">
<value>classpath:com/hibernate/bean/</value>
</property>
</bean>
</beans>