1

我想做这样的事情:

配置属性:

dsname=value;
anotherValue=anotherValue;

持久性.xml

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

1 回答 1

-1

属性文件在我的 Web 项目之外,我正在使用带有 EclipseLink 的 JPA,但我需要从外部文件值“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>
于 2012-06-26T14:01:55.240 回答