简体   繁体   English

如何读取persistence.xml的标记值 <jta-data-source> 从文件config.properties中输入

[英]How I can do to read the tag value for my persistence.xml <jta-data-source> in from a file config.properties

I want to do something like this: 我想做这样的事情:

config.properties: config.properties:

dsname=value;
anotherValue=anotherValue;

persitence.xml persitence.xml

<jta-data-source>${dsname}</jta-data-source>

The properties file is outside of my web project, I am using JPA with EclipseLink but I need to initialize the parameter jta-data-source from the external file value "dsname" 属性文件不在我的Web项目中,我正在将JPA与EclipseLink一起使用,但是需要从外部文件值“ dsname”初始化参数jta-data-source

actually: 其实:

<persistence-unit name="Unit-ejbPU" transaction-type="JTA">
  <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>datasource</jta-data-source>
      <class>Clase1</class>
      <class>Clase2</class>
      <class>Clase3</class>
  <properties/>
</persistence-unit>

idea to make: 产生的想法:

<persistence-unit name="Unit-ejbPU" transaction-type="JTA">
  <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>${dsname}</jta-data-source>
      <class>Clase1</class>
      <class>Clase2</class>
      <class>Clase3</class>
  <properties/>
</persistence-unit>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM