会员登录 - 用户注册 - 设为首页 - 加入收藏 - 网站地图 Spring Data开发手册|手把手教你简化持久层开发工作!

Spring Data开发手册|手把手教你简化持久层开发工作

时间:2025-11-04 13:34:56 来源:益强数据堂 作者:域名 阅读:883次
Spring Data开发手册|手把手教你简化持久层开发工作
复制 <?手册手把手教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"  xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:aop="http://www.springframework.org/schema/aop"  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/context          http://www.springframework.org/schema/context/spring-context.xsd          http://www.springframework.org/schema/tx          http://www.springframework.org/schema/tx/spring-tx.xsd          http://www.springframework.org/schema/aop          http://www.springframework.org/schema/aop/spring-aop.xsd          http://www.springframework.org/schema/data/jpa           http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd">          <!--引入Properties文件-->         <context:property-placeholder location="classpath:config/db.properties"/>          <!--配置c3p0的连接池-->         <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">              <property name="driverClass" value="${driverClass}"></property>              <property name="jdbcUrl" value="${url}"></property>              <property name="user" value="${user}"></property>              <property name="password" value="${password}"></property>              <property name="acquireIncrement" value="${acquireIncrement}"></property>              <property name="maxPoolSize" value="${maxPoolSize}"></property>              <property name="minPoolSize" value="${minPoolSize}"></property>              <property name="maxStatements" value="${maxStatements}"></property>          </bean>          <!--配置JPA实现产品的适配器-->         <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">          </bean>          <!--配置EntityManager对象-->         <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">             <!--注入数据源-->            <property name="dataSource" ref="dataSource"></property>             <!--扫描entity包的-->             <property name="packagesToScan" value="com.qy.helloworld"></property>             <!--注入JPA实现产品的适配器-->            <property name="jpaVendorAdapter" ref="jpaVendorAdapter"></property>             <!--配置的是Hibernate的其他配置  除了连接数据库4大要素之外的亿华云计算其余配置-->            <property name="jpaProperties">                <props>                 <!--是否自动创建表 -->                <prop key="hibernate.hbm2ddl.auto">update</prop>                 <!--配置是否展示SQL-->                <prop key="hibernate.show_sql">true</prop>                 <!--是否格式化SQL-->                <prop key="hibernate.format_sql">true</prop>                 <!--连接数据库的方言-->                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>              </props>             </property>          </bean>          <!--配置事务环境-->         <bean id="jpaTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">             <!--注入dataSource-->            <property name="dataSource" ref="dataSource"></property>             <!--注入entityManagerFactory对象-->            <property name="entityManagerFactory" ref="entityManagerFactory"></property>          </bean>          <!--使用事务-->         <tx:annotation-driven transaction-manager="jpaTransactionManager"/>          <!--配置AOP的自动代理-->         <aop:aspectj-autoproxy></aop:aspectj-autoproxy>           <!--配置Spring的包扫描-->         <context:component-scan base-package="com.qy.helloworld"></context:component-scan>          <!--Spring data的网站模板包的扫描  这里的扫描扫描的是DAO层所在的位置-->         <jpa:repositories base-package="com.qy.helloworld" entity-manager-factory-ref="entityManagerFactory"transaction-manager-ref="jpaTransactionManager"></jpa:repositories>  </beans>          1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.

(责任编辑:数据库)

推荐内容
  • 简便易行的方法(一步步教你重装联想S41,省时又省力)
  • K2路由器刷不死breed教程(让你的K2路由器焕发第二春!)
  • 用U盘安装Windows7系统教程(详细步骤让您轻松搞定系统安装)
  • 以蓝盛蓝牙耳机如何改善音频体验(领先技术打造高品质无线音乐享受)
  • 探索dostylesd805的风格魅力(发现dostylesd805独特设计与创新科技的奇妙融合)
  • 快速去除PDF水印软件的选择(解放工作效率,轻松消除PDF文件中的水印问题)