java - 无法生成 hibernate.reveng.xml,因为 hibernate.connection.url 是动态的

标签 java hibernate hibernate-tools

我想生成一个hibernate.reveng.xml,但是hibernate.cfg.xml中的“hibernate.connection.URL” > 是一个变量。

jdbc:jtds:sqlserver://${database.server.name}:1433/XXX_DB

所以我的问题是如何让hibernate-tool知道变量在哪里定义?

最佳答案

您可以在 ant 任务中指定 .properties 文件(将包含此内容)的路径:

hibernate.connection.url=jdbc:mysql://127.0.0.1:1433/XXX_DB
hibernate.connection.username=xxx
hibernate.connection.password=yyy

然后,在 Ant 任务中:

<hibernatetool ...>

   <jdbcconfiguration configurationfile="pathTo/your.cfg.cml"
                      propertyfile="pathTo/your.file.properties"/>

希望对你有帮助 迭戈。

关于java - 无法生成 hibernate.reveng.xml,因为 hibernate.connection.url 是动态的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14155500/

相关文章:

java - Hibernate通过java注释将java中的嵌套集合映射到映射表?

mysql - 我在哪里可以看到 Eclipse 中的差异 "Hibernate Console Configurations"

java - 使用 Hibernate 工具为数据库中的单个表生成 .hbm 文件

Java Android : BufferedInputStream to byte Array

java - 访问java类的方法的最佳方法是创建对象或使方法成为静态类型?

java - 添加不同位置的圆圈

java - 为一组给定的日期字符串生成正则表达式

java - 哪一种最高效-HQL

java - 服务委托(delegate)抛出 "LazyInitializationException: could not initialize proxy - no Session"

eclipse - 使用 hibernate 工具从 Postgres 逆向工程 pojos