ssh applicationContext.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd">


<!-- 扫描注解 -->


<context:component-scan base-package="com.lanou"></context:component-scan>


<!-- 读取配置文件 -->
<context:property-placeholder location="classpath*:*.properties" />


<!-- 数据源 druid -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="url" value="${jdbc.url}"></property>
<property name="username" value="${jdbc.loginName}"></property>
<property name="password" value="${jdbc.pwd}"></property>
<property name="driverClassName" value="${jdbc.driver}"></property>
</bean>
<!-- 会话工程 -->


<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<!-- 注入数据源 -->
<property name="dataSource" ref="dataSource"></property>
<!-- hibernate 属性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.current_session_context_class">${hibernate.session}</prop>
</props>
</property>


<!-- 扫描实体映射文件 -->
<property name="mappingLocations">
<list>
<value>classpath:com/lanou/entity/*.hbm.xml</value>

</list>
</property>
</bean>
<!-- 配置hibernate4事物管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>

猜你喜欢

转载自blog.csdn.net/corelife/article/details/80705328
今日推荐