0

Following is my persistance.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2"
    xmlns="http://xmlns.jcp.org/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">

    <persistence-unit name="IntegratorMasterdataDS"
        transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
<!--        <jta-data-source>java:/datasources/IDS1</jta-data-source>  -->
        <jta-data-source>java:/datasources/IDS</jta-data-source>
        <properties>
            <property name="hibernate.archive.autodetection" value="class" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.generate_statistics" value="true"/>
        </properties>
    </persistence-unit>
</persistence>

When i need to build with production profile i need to comment and uncomment in above persistance.xml.

Is there any way in maven build to supply values during runtime in persistance.xml? (i remember in old projects i see {something.some} but not able to find how to use it in my use case?)

fatherazrael
  • 5,511
  • 16
  • 71
  • 155

1 Answers1

0

Locate your persistence.xml into a a location like src/main/resources/PATH and use the filtering. Add a tag to POM and set it to true like this: Details Here

<resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
Mayank Tripathi
  • 340
  • 2
  • 16
  • This appears will not fix program, in this case then i have to be dependent on Pom.XML because after all i need to give single property name say ${jtaname} but how can i supply it on runtime? – fatherazrael Jan 17 '20 at 11:04