persistence.xml(JPA)中的环境变量扩展 [英] Environment variable expansion in persistence.xml (JPA)
问题描述
我试图通过一个变量指定数据库路径给运行时的JVM。
该属性设置正确,但数据库是以变量名称(以下为$ {DBHOME})命名的文件夹中创建的。
code>< property name =javax.persistence.jdbc.urlvalue =jdbc:derby:$ {DBHOME}; create = true/>
有没有可能解决这个问题?
Thx
应该适用于JVM变量,而不是OS / Shell环境变量。为了使您的示例工作,您需要使用 -DDBHOME = your / path
启动JVM。
这个工作与shell变量,你需要添加 -DDBHOME = $ DBHOME
(* nix)或 -DDBHOME =%DBHOME%
(win)到JVM启动命令行。
I am developing a Eclipse RCP plugin which uses JPA. I tried to specify the database path via a variable give to the JVM on runtime. The property is set correctly but the database is created in a folder named after the variable name (here: ${DBHOME}).
<property name="javax.persistence.jdbc.url" value="jdbc:derby:${DBHOME};create=true"/>
Is there a possibility to fix this?
Thx
That should work but only for JVM variables, not OS/Shell environment variables. To make your example work, you need to start the JVM with -DDBHOME=your/path
.
To make this work with shell variables, you need to add -DDBHOME=$DBHOME
(*nix) or -DDBHOME=%DBHOME%
(win) to the JVM launch command line.
这篇关于persistence.xml(JPA)中的环境变量扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!