可以为多个数据源配置persistence.xml吗? [英] it's possible configure a persistence.xml for multiple data sources?

查看:703
本文介绍了可以为多个数据源配置persistence.xml吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我只想知道如何在persistence.xml中配置两个数据源,其中一个数据源的jar在另一个之外。我试过但是如果可能的话我真的不会

hi i just want to know how configure in a persistence.xml two datasources one of the data sources have a jar outside from the other. I'm tried but i really don't if it's possible

推荐答案

是的,你可以在持久性中配置两个数据源。 XML。你只需要两个独立的元素。

Yeah, you can have two datasources configured in a persistence.xml. You would just need two separate elements.

<persistence>
   <persistence-unit name="datasourceOne">
       <jta-data-source>java:/DefaultDS</jta-data-source>
       <jar-file>../MyApp.jar</jar-file>
       <class>org.acme.Employee</class>
       <class>org.acme.Person</class>
       <class>org.acme.Address</class>
       <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
            <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
       </properties>
   </persistence-unit>

   <persistence-unit name="datasourceTwo">
     <!-- some configuration -->
  </persistence-unit>
</persistence>

这篇关于可以为多个数据源配置persistence.xml吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆