前后两天花了7个多小时,搜索了整个网络的心血研究成果,基于hibernate的很好找,但基于eclipselink的资料少之又少,我最终解决了也是看了大量资料的灵机一动,废话不说了,也不想做解释了,明白人一看就明白。我可以肯定地说,到今天为止,网上还没有一个可用的配置文件,我这是蝎子耙耙独一份儿,哈哈。参照下面的例子,你也会解决的。
<?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:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.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-4.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd"> <context:property-placeholder location="classpath:jdbc.properties"/> <!--<jee:jndi-lookup jndi-name="test" id="dataSource" resource-ref="true"/>--> <bean abstract="true" id="baseDS" class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" lazy-init="true"> <property name="pinGlobalTxToPhysicalConnection" value="true" /> <property name="user" value="root" /> <property name="password" value="root" /> </bean> <bean id="dataSource1" parent="baseDS"> <property name="url"> <value>${jdbc1.url}</value> </property> </bean> <bean id="dataSource2" parent="baseDS"> <property name="url"> <value>${jdbc2.url}</value> </property> </bean> <bean id="baseJTADS" class="com.atomikos.jdbc.AtomikosDataSourceBean" abstract="true" init-method="init" destroy-method="close"> <property name="poolSize" value="3" /> </bean> <bean id="jtaDs1" parent="baseJTADS"> <property name="uniqueResourceName" value="XA1DBMS" /> <property name="xaDataSource" ref="dataSource1" /> </bean> <bean id="jtaDs2" parent="baseJTADS"> <property name="uniqueResourceName" value="XA2DBMS" /> <property name="xaDataSource" ref="dataSource2" /> </bean> <bean abstract="true" id="baseEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"/> </property> <property name="packagesToScan" value="org.fxbird.springjpa.model"/> <property name="jpaProperties"> <props> <prop key="databasePlatform">org.eclipse.persistence.platform.database.MySQLPlatform</prop> <prop key="eclipselink.jdbc.cache-statements">true</prop> <prop key="eclipselink.weaving">false</prop> <prop key="eclipselink.logging.level">FINEST</prop> <prop key="eclipselink.allow-zero-id">true</prop> <prop key="eclipselink.target-server">com.atomikos.eclipselink.platform.AtomikosTransactionController</prop> <prop key="eclipselink.external-transaction-controller">true</prop> </props> </property> </bean> <bean id="emfCompany" parent="baseEmf"> <property name="jtaDataSource" ref="jtaDs1"/> <property name="persistenceUnitName" value="emfC"/> </bean> <bean id="emfEmp" parent="baseEmf"> <!--<property name="persistenceUnitName" value="employee" />--> <property name="jtaDataSource" ref="jtaDs2"/> <property name="persistenceUnitName" value="emfE"/> </bean> <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"> <property name="transactionTimeout" value="300"/> </bean> <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close"> <property name="forceShutdown" value="true"/> <property name="transactionTimeout" value="300"/> </bean> <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="transactionManager" ref="atomikosTransactionManager"/> <property name="userTransaction" ref="atomikosUserTransaction"/> <!--<property name="allowCustomIsolationLevels" value="true"/>--> </bean> <context:component-scan base-package="org.fxbird.springjpa.service"/> <jpa:repositories base-package="org.fxbird.springjpa.repo.company" entity-manager-factory-ref="emfCompany" transaction-manager-ref="transactionManager"> </jpa:repositories> <jpa:repositories base-package="org.fxbird.springjpa.repo.emp" entity-manager-factory-ref="emfEmp" transaction-manager-ref="transactionManager"> </jpa:repositories> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" /> <aop:aspectj-autoproxy proxy-target-class="true" /> <context:annotation-config/> </beans>
相关推荐
基于SpringBoot+Spring Data JPA+mybatis的仓库管理系统 基于SpringBoot+Spring Data JPA+mybatis的仓库管理系统 基于SpringBoot+Spring Data JPA+mybatis的仓库管理系统 基于SpringBoot+Spring Data JPA+mybatis的...
1、基于SpringBoot+Spring Data JPA+mybatis的仓库管理系统源码.zip 2、该资源包括项目的全部源码,下载可以直接使用! 3、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考...
基础框架,可满足开发需要
SpringMVC+Spring Data JPA+Shiro+EasyUI 整合的简单demo
NULL 博文链接:https://remotejavasky.iteye.com/blog/1182721
技术架构:SpringMVC3+Spring3.1.2+Spring Data JPA+Maven 声明:该应用仅仅是技术研究:Spring Data JPA的配置和常见api的使用&maven构建项目,其他技术不在此研究 内涵sql和各种Spring Data JPA测试和案例,导入&...
Spring Boot+Maven+Spring Data JPA+apache Shiro+Easyui实现通用用户权限管理系统
SpringBoot+Spring data JPA+FreeMarker+shiro+log4jdbc
基于SpringBoot+SpringDataJPA+Mysql的课表排课及实验室机房管理系统
springboot+springdatajpa+thymeleaf+shiro 的管理平台框架
SpringBoot + SpringData Jpa + Scala + Mysql(java+Scala混编)
技术架构:SpringMVC4+Spring4+Spring Data JPA+hibernate4+Maven 声明:查了好多资料,下载了好多代码,发现没有几个能运行起来的,于是写下此代码,希望能够帮助后来者。此程序导入&创建DB,配置好maven便可运行。...
spring+springmvc+spring data jpa+mysql代码示例。运行前需创建数据库sssp并修改相关数据库配置
TIMO后台管理系统,基于SpringBoot2.0 + Spring Data Jpa + Thymeleaf + Shiro 开发的后台管理系统,采用分模块的方式便于开发和维护,支持前后台模块分别部署,目前支持的功能有:权限管理、部门管理、字典管理、...
本资源后台使用Java,前端使用angular5,后台是springdata JPA+springmvc+hibernate写的一个小例子,数据库表自动生成,注意修改MySQL 配置及angular地址访问路径
项目描述 企业的销售要进行培训,由技术人员进行辅导并考评检测培训效果,所以有了这个小系统。实现了系统的登录验证、请求拦截验证、基础...springboot + spring data jpa + layui http://localhost/ zuidaima 111111
2017 spring data jpa+spring4.2+springmvc+hibernate4.3 maven环境intellij idea增删改查实例
基于springboot+thymeleaf+spring data jpa+druid+bootstrap+layui等技术的JavaWeb电商项目(项目包含前后台,分为前台商城系统及后台管理系统。前台商城系统包含首页门户
项目描述 本系统采用企业级开发标准,使用SpringBoot架构,数据访问层采用Spring Data Jpa,业务控制层采用SpringMvc,安全框架采用Shiro,实现了完整权限系统,...SpringBoot+Spring Data Jpa+shiro+easyui+bootstrap