打包一个可运行的JPA jar,将persistence.xml放在外面 [英] Package a runnable JPA jar putting persistence.xml outside
问题描述
我想将我的jpa / swing项目导出到一个可运行的jar中。但我希望persistence.xml不在包装里面的jar之外,所以我可以在不需要在每次配置后再次导出jar的情况下更改它。
I want to export my jpa/swing project to a runnable jar. But I want the persistence.xml to be outside the jar not packaged inside, so I can change it without the need to export the jar again after each config.
推荐答案
根据JPA规范,在定义持久性单元的JAR文件之外无法检测到 persistence.xml
文件。按照惯例,它应放在 META-INF
目录中。
According to JPA specifications, persistence.xml
file cannot be detected outside the JAR file where the persistence unit is defined. By convention, it should be placed inside META-INF
directory.
阅读JSR-317,第8.2.1段有关详细信息( http://download.oracle。 com / otndocs / jcp / persistence-2.0-fr-eval-oth-JSpec / )。
Read JSR-317, paragraph 8.2.1 for more details (http://download.oracle.com/otndocs/jcp/persistence-2.0-fr-eval-oth-JSpec/).
尽管如此,你可以试试这个家伙提出的提示此处并以分解形式部署您的档案。
Nevertheless, you can try the hint proposed by this guy here and deploy your archives in exploded form.
这篇关于打包一个可运行的JPA jar,将persistence.xml放在外面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!