簡體   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

我想做這樣的事情:

config.properties:

dsname=value;
anotherValue=anotherValue;

persitence.xml

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

屬性文件不在我的Web項目中,我正在將JPA與EclipseLink一起使用,但是需要從外部文件值“ dsname”初始化參數jta-data-source

其實:

<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>

產生的想法:

<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