简体   繁体   中英

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:

dsname=value;
anotherValue=anotherValue;

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"

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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