configure Spring Data JPA by using XML
来源:互联网 发布:中国空运交通运输网络 编辑:程序博客网 时间:2024/06/06 02:50
if you want to configure Spring Data JPA by using XML configuration (and use the configuration described in the book), you have to follow these steps:
- Configure the data source bean.
- Configure the entity manager factory bean.
- Configure the transaction manager bean.
- Enable annotation driven transaction management.
- Configure Spring Spring Data JPA.
<?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:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" 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.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> <!-- Configure the data source bean --> <jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/CustomerSupport"/> <!-- Create default configuration for Hibernate --> <bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/> <!-- Configure the entity manager factory bean --> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/> <!-- Set JPA properties --> <property name="jpaProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop> <prop key="javax.persistence.schema-generation.database.action">none</prop> <prop key="hibernate.ejb.use_class_enhancer">true</prop> </props> </property> <!-- Set base package of your entities --> <property name="packagesToScan" value="foo.bar.model"/> <!-- Set share cache mode --> <property name="sharedCacheMode" value="ENABLE_SELECTIVE"/> <!-- Set validation mode --> <property name="validationMode" value="NONE"/> </bean> <!-- Configure the transaction manager bean --> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <!-- Enable annotation driven transaction management --> <tx:annotation-driven/> <!-- Configure Spring Data JPA and set the base package of the repository interfaces --> <jpa:repositories base-package="foo.bar.repository"/></beans>
0 0
- configure Spring Data JPA by using XML
- Spring Data JPA Using @Query
- Spring Data JPA repositories using JavaConfig
- Update an entity using spring data JPA
- Jpa到Spring data jpa
- Spring Data JPA applicationContext.xml 配置文件报错的解决办法
- applicationContext.xml里面抽取spring data jpa之后报错
- Spring Data JPA
- Spring-Data-Jpa
- Spring Data JPA
- Spring data jpa
- Spring Data JPA 使用
- Spring Data JPA
- Spring Data JPA
- spring data JPA 配置
- Spring Data JPA
- Spring Jpa Data
- spring-data-jpa 使用
- nmealib代码分析
- 空闲时间学一个Linux命令(10)—— cat 命令
- 面向接口编程(1)--思想基础
- Object_C内存管理
- 初识Spring Boot框架
- configure Spring Data JPA by using XML
- 真正的java的四舍五入
- Python smtplib发送邮件 包含文本、附件、图片等
- Spring 配置 druid数据库连接
- Linux双网卡bonding操作方法
- 关于SCSS入门功能(上)
- ZCMU-1158-二叉树
- [modules] -- 设置别名,生成模块
- 【Java】HttpClient 使用(代码整理)