1

How can I configure persistence.xml for production? My question specifically concerns the definition of parameters such as user, password and bank url, for example.

I would like to not include this data directly in the file, but in an environment variable, for example.

However, it can be any other approach, except overwriting the file settings via the entity manager factory as was said in these questions 1 e 2

This restriction exists because my EntityManager is injected via @PersistenceContext. This even generated a comment

I'm using a JavaEE application with JAX-RS, Hibernate JPA and Spring MVC

3
  • It's a JavaSE application or JavaEE? If you are on a JavaEE server you should use a datasource to provide connections Commented Apr 3, 2020 at 5:13
  • I edited the question and a i included: I'm using a JavaEE application with JAX-RS, Hibernate JPA and Spring MVC. However, can you detail more what you said about "use a datasource to provide connections? @areus" Commented Apr 3, 2020 at 14:04
  • On a JavaEE server you can define a datasource, with all the connection properties, and on the persistence.xml you only need to add the <jta-datasource> tag referencing the JNDI name of the datasource. Commented Apr 4, 2020 at 14:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.