applicationContent.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:tx="http://www.springframework.org/schema/tx"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  7. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
  8. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
  9.  
  10. <!-- 配置自动扫描的包 -->
  11. <context:component-scan base-package="com.atguigu.jpa"></context:component-scan>
  12.  
  13. <!-- 配置 C3P0 数据源 -->
  14. <context:property-placeholder location="classpath:db.properties"/>
  15.  
  16. <bean id="dataSource"
  17. class="com.mchange.v2.c3p0.ComboPooledDataSource">
  18. <property name="user" value="${jdbc.user}"></property>
  19. <property name="password" value="${jdbc.password}"></property>
  20. <property name="driverClass" value="${jdbc.driverClass}"></property>
  21. <property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
  22.  
  23. <!-- 配置其他属性 -->
  24. </bean>
  25.  
  26. <!-- 配置 EntityManagerFactory -->
  27. <bean id="entityManagerFactory"
  28. class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  29. <property name="dataSource" ref="dataSource"></property>
  30. <!-- 配置 JPA 提供商的适配器. 可以通过内部 bean 的方式来配置 -->
  31. <property name="jpaVendorAdapter">
  32. <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"></bean>
  33. </property>
  34. <!-- 配置实体类所在的包 -->
  35. <property name="packagesToScan" value="com.atguigu.jpa.spring.entities"></property>
  36. <!-- 配置 JPA 的基本属性. 例如 JPA 实现产品的属性 -->
  37. <property name="jpaProperties">
  38. <props>
  39. <prop key="hibernate.show_sql">true</prop>
  40. <prop key="hibernate.format_sql">true</prop>
  41. <prop key="hibernate.hbm2ddl.auto">update</prop>
  42. </props>
  43. </property>
  44. </bean>
  45.  
  46. <!-- 配置 JPA 使用的事务管理器 -->
  47. <bean id="transactionManager"
  48. class="org.springframework.orm.jpa.JpaTransactionManager">
  49. <property name="entityManagerFactory" ref="entityManagerFactory"></property>
  50. </bean>
  51.  
  52. <!-- 配置支持基于注解是事务配置 -->
  53. <tx:annotation-driven transaction-manager="transactionManager"/>
  54.  
  55. </beans>

db.properties

  1. jdbc.user=root
  2. jdbc.password=1230
  3. jdbc.driverClass=com.mysql.jdbc.Driver
  4. jdbc.jdbcUrl=jdbc:mysql:///jpa

jpa-spring -basic的更多相关文章

  1. JPA && Spring Data && Spring Data JPA

    1.JPA  Java Persistence API,用于对象持久化的一组API,JPA本身是一组规范,让开发者用同一种方式访问不同的ORM框架.其实也就是java实体对象和关系型数据库建立起映射关 ...

  2. JPA Spring Data 概述

    JPA Spring Data : 致力于减少数据访问层 (DAO) 的开发量. 开发者唯一要做的,就只是声明持久层的接口,其他都交给 Spring Data JPA 来帮你完成! 框架怎么可能代替开 ...

  3. Spring boot 整合spring Data JPA+Spring Security+Thymeleaf框架(上)

    近期上班太忙所以耽搁了给大家分享实战springboot 框架的使用. 以下是spring boot 整合多个框架的使用. 首先是准备工作要做好. 第一  导入框架所需的包,我们用的事maven 进行 ...

  4. jpa+spring配置多数据源

    property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/test?useU ...

  5. spring boot(五):spring data jpa的使用

    在上篇文章springboot(二):web综合开发中简单介绍了一下spring data jpa的基础性使用,这篇文章将更加全面的介绍spring data jpa 常见用法以及注意事项 使用spr ...

  6. Spring与JPA

    Java持久化API(Java Persistence API),即JPA Spring中使用JPA的第一步是要在Spring应用上下文中将实体管理器工厂(entity manager factory ...

  7. Spring Data Jpa 详解

    前言: JPA全称Java Persistence API,即Java持久化API,它为Java开发人员提供了一种对象/关系映射工具来管理Java应用中的关系数据,结合其他ORM的使用,能达到简化开发 ...

  8. Spring Data Jpa 详解 (配置篇)

    前言: JPA全称Java Persistence API,即Java持久化API,它为Java开发人员提供了一种对象/关系映射工具来管理Java应用中的关系数据,结合其他ORM的使用,能达到简化开发 ...

  9. Spring Data Jpa+SpringMVC+Jquery.pagination.js实现分页

    本博客介绍基于Spring Data这款orm框架加上Jquery.pagination插件实现的分页功能. 介绍一下Spring Data框架 spring Data : Spring 的一个子项目 ...

  10. SpringBoot入门:Spring Data JPA 和 JPA(理论)

    参考链接: Spring Data JPA - Reference Documentation Spring Data JPA--参考文档 中文版 纯洁的微笑:http://www.ityouknow ...

随机推荐

  1. 自动AC机

    可以在lemon和cena环境下使用. #include<iostream> #include<cstdio> #include<cstring> #include ...

  2. 设置tab标签页 遮挡部分

    效果如下: 主要代码: <div class="need-detail"> <div class="top-title"> <sp ...

  3. TensorFlow 官方文档中文版学习

    TensorFlow 官方文档中文版 地址:http://wiki.jikexueyuan.com/project/tensorflow-zh/

  4. 记录一下 FastAdmin getOriginData 问题

    记录一下 FastAdmin getOriginData 问题 FastAdmin 对 用户端新增了一个 money 字段,但在后台修改时出错,提示没有 getOriginData 方法. 跟踪了一下 ...

  5. mime type 类型名字应该用多长的字段?

    在使用 FastAdmin 时有 mimetype 字段使用了 50 长度,有小伙伴反应,不够. 在 Linux 服务器上时 xlsx 文件的 mimetype  是 application/vnd. ...

  6. php curl伪造来源ip和refer实例代码

    php curl伪造来源ip和来路refer实例代码1: //随机IP function Rand_IP(){ $ip2id= round(rand(600000, 2550000) / 10000) ...

  7. bzoj 2286(洛谷 2495) [Sdoi2011]消耗战——虚树

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2286 https://www.luogu.org/problemnew/show/P2495 ...

  8. 最新hadoop入门教程汇总篇(附详细图文步骤)

    关于hadoop的分享此前一直都是零零散散的想到什么就写什么,整体写的比较乱吧.最近可能还算好的吧,毕竟花了两周的时间详细的写完的了hadoop从规划到环境安装配置等全部内容.写过程不是很难,最烦的可 ...

  9. JZ2440 裸机驱动 第7章 内存管理单元MMU

    本章目标:     了解虚拟地址和物理地址的关系:     掌握如何通过设置MMU来控制虚拟地址到物理地址的转化:     了解MMU的内存访问权限机制:     了解TLB.Cache.Write ...

  10. AI(四): 微信与luis结合(下)

    LUIS(Language Understanding Intelligent Services)是微软新近推出了的的语义理解服务,可以方便用户进行API调用,创建自己场景的语义理解服务,网址为 ht ...