<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
">

<!-- 开启对注解的支持 -->
<context:annotation-config/>
<!-- 扫描src下所有的包 -->
<context:component-scan base-package="com.bdqn.*"/>

<!-- 引入配置文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:jdbc.properties" />
</bean>

<!--1 配置数据源-->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="url" value="${url}"></property>
<property name="driverClassName" value="${driver}"></property>
<property name="username" value="${username}"></property>
<property name="password" value="${password}"></property>
</bean>

<!--2 配置EntityManagerFactory-->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
<property name="packagesToScan" value="com.bdqn"/>

<property name="jpaProperties">
<props>
<prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>

</bean>

<!--3 配置事务管理器-->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>

<!--4 配置支持注解的事务-->
<tx:annotation-driven transaction-manager="transactionManager"/>

<!--5 配置spring data-->
<!-- 自动扫描并注入Spring Data JPA -->
<jpa:repositories base-package="com.bdqn"
entity-manager-factory-ref="entityManagerFactory"
transaction-manager-ref="transactionManager" />

</beans>

最新文章

  1. doT.js学习
  2. ASP.NET MVC 概述
  3. mui日期插件$, each遍历,EventListener事件监听,json格式
  4. 0019 Java学习笔记-面向对象-方法
  5. GMT与UTC简介
  6. [BZOJ 1797][AHOI2009]最小割(最小割关键边的判断)
  7. BZOJ1507 [NOI2003]Editor
  8. Contest 20140914 Mushroom写情书 字符串雙hash 後綴數組
  9. Javascript之模拟文字高亮
  10. 把玩爬虫框架Gecco
  11. VS中代码覆盖问题
  12. linux命令dd
  13. linux命令TOP参数load average详解[转]
  14. JS基础学习3
  15. 【学习笔记】《Python从入门到实践》游戏-Alien Invasion
  16. Oracle中数值的计算
  17. 驱动文件中只有cat/inf/dll文件,怎么安装
  18. js 生成随机颜色
  19. jQuery之禁止Get请求缓存
  20. Web开发——服务器端应用技术简单比较

热门文章

  1. STL源码剖析——序列式容器#5 heap
  2. docker 的Portainer和Dive
  3. 【转】潜说js对象和数组
  4. Schnorr签名介绍
  5. 版本控制器:Git-的使用
  6. 换个语言学一下 Golang (10)——并行计算
  7. 【Java深入研究】11、深入研究hashmap中的hash算法
  8. Crontab常用命令总结
  9. Java深入学习(4):Future模式
  10. 没有用到React,为什么我需要import引入React?