persistence.xml(JPA)中的环境变量扩展 [英] Environment variable expansion in persistence.xml (JPA)

查看:178
本文介绍了persistence.xml(JPA)中的环境变量扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用JPA的Eclipse RCP插件。
我试图通过一个变量指定数据库路径给运行时的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆