`

spring data jpa+eclipselink+jta+atomikos的配置(全网独一无二的研究结果)

阅读更多

前后两天花了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>

 

0
1
分享到:
评论
2 楼 theoffspring 2015-04-13  
sgq0085 写道
真有人在用eclipselink么?

嗯,我们项目就在用。如果我做决定的话,我不会选这个用的人这么少的东西,没办法。老大让用的
1 楼 sgq0085 2015-04-13  
真有人在用eclipselink么?

相关推荐

    基于SpringBoot+Spring Data JPA+mybatis的仓库管理系统.zip

    基于SpringBoot+Spring Data JPA+mybatis的仓库管理系统 基于SpringBoot+Spring Data JPA+mybatis的仓库管理系统 基于SpringBoot+Spring Data JPA+mybatis的仓库管理系统 基于SpringBoot+Spring Data JPA+mybatis的...

    基于SpringBoot+Spring Data JPA+mybatis的仓库管理系统源码.zip

    1、基于SpringBoot+Spring Data JPA+mybatis的仓库管理系统源码.zip 2、该资源包括项目的全部源码,下载可以直接使用! 3、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考...

    Spring +JPA+EclipseLink Maven 配置

    本篇文章将深入探讨如何配置Spring、JPA(EclipseLink实现)和Maven来创建一个高效且易于维护的Java应用程序。 首先,我们需要在`pom.xml`文件中添加相关的依赖。Spring的核心模块包括`spring-context`和`spring-...

    手动创建 SpringMvc +SpringDataJpa+Hibernate+ freemarker mavenProject+ 环境切换 webDemo

    在本项目中,我们主要探讨如何手动构建一个基于SpringMVC、Spring Data JPA、Hibernate以及FreeMarker模板引擎的Maven工程,同时实现环境切换功能。这个基础框架为日常开发工作提供了必要的支持。 首先,SpringMVC...

    SpringMVC+Spring+Spring Data JPA+Maven

    技术架构:SpringMVC3+Spring3.1.2+Spring Data JPA+Maven 声明:该应用仅仅是技术研究:Spring Data JPA的配置和常见api的使用&maven构建项目,其他技术不在此研究 内涵sql和各种Spring Data JPA测试和案例,导入&...

    基于SpringBoot+SpringDataJPA+Mysql的课表排课及实验室机房管理系统

    《构建基于SpringBoot+SpringDataJPA+Mysql的课表排课及实验室机房管理系统》 在现代教育信息化管理中,课表排课及实验室机房管理是至关重要的环节。借助于先进的技术和框架,我们可以构建高效、智能的管理系统。本...

    SpringMVC+Spring Data JPA+Shiro+EasyUI 简单demo

    "SpringMVC+Spring Data JPA+Shiro+EasyUI 简单demo"是一个整合了上述四个技术的Web应用示例。这个项目可能包含了以下组件: 1. **配置文件**:如`applicationContext.xml`用于配置SpringMVC和Spring Data JPA,...

    springboot+springdatajpa+thymeleaf+shiro 的管理平台框架

    综上所述,SpringBoot+SpringDataJPA+Thymeleaf+Shiro的组合为开发高效、安全的管理平台提供了坚实的基础。它们各自负责不同的层面:SpringBoot负责项目结构和运行环境,SpringDataJPA处理数据访问,Thymeleaf实现...

    spring+SpringMVC+Spring Data JPA+Maven(增删该查功能齐全)

    技术架构:SpringMVC4+Spring4+Spring Data JPA+hibernate4+Maven 声明:查了好多资料,下载了好多代码,发现没有几个能运行起来的,于是写下此代码,希望能够帮助后来者。此程序导入&创建DB,配置好maven便可运行。...

    Spring Boot+Maven+Spring Data JPA+apache Shiro+Easyui实现通用用户权限管理系统

    本项目基于"Spring Boot+Maven+Spring Data JPA+apache Shiro+Easyui",这些技术栈的选择旨在简化开发过程,提供强大的功能,并确保系统的安全性和用户体验。 1. **Spring Boot**: Spring Boot是Spring框架的简化版...

    Spring+SpringMVC+SpringDataJPA+Hibernate

    在本文中,我们将深入探讨"Spring+SpringMVC+SpringDataJPA+Hibernate"这个集成框架,这是一个在Java开发中广泛使用的强大组合,用于构建高效、可扩展的企业级应用程序。 首先,Spring是一个全面的Java应用框架,它...

    CRM营销系统 spring+springmvc+springdatajpa+jsp+maven

    3. SpringDataJPA:SpringDataJPA是Spring框架的一个模块,它简化了Java持久化层的开发,特别是使用Java Persistence API (JPA)。在CRM系统中,SpringDataJPA可能被用来与MySQL数据库进行交互,自动执行CRUD操作,如...

    spring data jpa + spring + json demo

    【标题】"spring data jpa + spring + json demo"揭示了这个项目是关于使用Spring Data JPA、Spring框架以及JSON处理的一个示例应用。Spring Data JPA是Spring框架的一个模块,它简化了JPA(Java Persistence API)...

    SpringBoot+Spring data JPA+FreeMarker+shiro+log4jdbc

    它提供了对ORM(对象关系映射)供应商如Hibernate、EclipseLink等的一致性支持。通过Spring Data JPA,开发者可以利用泛型接口和方法命名规则,轻松实现CRUD操作,同时提供了查询构造器和动态查询功能,降低了与...

    SpringBoot + SpringData Jpa + Scala + Mysql(java+Scala混编)

    SpringData JPA是Spring框架的一个模块,用于简化JPA(Java Persistence API)的使用。它提供了一个统一的API来访问各种持久化技术,如Hibernate、EclipseLink等。通过SpringData JPA,你可以利用注解驱动的方法来...

    spring+springmvc+spring data jpa+mysql

    标题 "spring+springmvc+spring data jpa+mysql" 涉及到的是一个基于Java的Web开发技术栈,主要用于构建高效、灵活的企业级应用程序。这个技术组合包括四个主要组件: 1. **Spring框架**:这是一个全面的企业级应用...

    基于SpringBoot2.0 + Spring Data Jpa + Thymeleaf + Shiro 开发的后台管理系统

    TIMO后台管理系统,基于SpringBoot2.0 + Spring Data Jpa + Thymeleaf + Shiro 开发的后台管理系统,采用分模块的方式便于开发和维护,支持前后台模块分别部署,目前支持的功能有:权限管理、部门管理、字典管理、...

    基于springboot+thymeleaf+spring data jpa+druid+bootstrap+layui等技术的JavaWeb电商项目

    基于springboot+thymeleaf+spring data jpa+druid+bootstrap+layui等技术的JavaWeb电商项目(项目包含前后台,分为前台商城系统及后台管理系统。前台商城系统包含首页门户

    基于javaConfig的springDataJpa+dubbo+springMvc搭建

    在提供的文件列表中,"基于javaConfig的springDataJpa+dubbo+springMvc搭建.txt"可能包含详细的搭建步骤和示例代码,"pom.xml"是项目的依赖管理文件,"sdk"和"web"、"app"可能是项目代码或资源文件的目录。...

    基于Spring Boot+Spring Data Jpa+apache shiro+easyui+bootstrap的推酷网站

    项目描述 本系统采用企业级开发标准,使用SpringBoot架构,数据访问层采用Spring Data Jpa,业务控制层采用SpringMvc,安全框架采用Shiro,实现了完整权限系统,...SpringBoot+Spring Data Jpa+shiro+easyui+bootstrap

Global site tag (gtag.js) - Google Analytics