Externalize credentials from persistence.xml in J2SE app

前端 未结 1 797
野趣味
野趣味 2021-01-03 07:02

I\'m writing a J2SE app (no enterprise container) that uses JPA for persistence. Here is my persistence.xml:



        
相关标签:
1条回答
  • 2021-01-03 07:53

    You can provide additional properties when creating EntityManagerFactory:

    Map<String, String> properties = new HashMap<String, String>();
    properties.put("javax.persistence.jdbc.user", ...);
    ...
    
    emf = Persistence.createEntityManagerFactory("dbstats", properties); 
    
    0 讨论(0)
提交回复
热议问题