gpt4 book ai didi

java - 可以使用 8.4 和 9.0 postgres( hibernate )库构建一个 .war 文件吗?

转载 作者:搜寻专家 更新时间:2023-10-31 19:34:37 24 4
gpt4 key购买 nike

到目前为止,我们一直在使用 Maven 依赖项来指定库,即:

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.10.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>3.6.10.Final</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.4-702.jdbc4</version>
</dependency>

但是,我们现在在不同的机器上运行完全相同的 .war 文件,并且希望保持相同的 One-war-file-to-rule-them-all,但不想通过使用来解决问题postgres 9.1 安装上的较旧驱动程序(例如,尤其是当字节数组编码默认值已更改时)。 Cliff-Claven 之类的信息可能无关紧要,但还是添加了:这两个安装的操作系统都是 Mac OS X Server,Postgres 8.4 运行在 10.6 上,9.1 运行在 10.7 上。我们不需要升级任何数据(从头开始的单独实例)。

也许这比其他任何问题更像是一个专家问题,但我似乎看不出有什么特别适合我的情况。我确实找到了 this ,但它是较旧的 Hibernate 3.5,不再适用。

最佳答案

对于 PostgreSQL,无论服务器版本如何,都应该使用最新版本的 JDBC 驱动程序,除非是真正非常古老的版本。

http://jdbc.postgresql.org/download.html#current说:

This is the current version of the driver. Unless you have unusual requirements (running old applications or JVMs), this is the driver you should be using. It supports Postgresql 7.2 or newer and requires a 1.4 or newer JVM.

对于 PostgreSQL JDBC 驱动程序,由于修复了错误并添加了功能,因此它们通常只会进入最新版本。较新的 JDBC 驱动程序版本可以识别较旧的服务器版本,并将根据服务器版本正确运行。

请注意,较旧的 JDBC 驱动程序无法识别较新的服务器版本,事实上,使用比服务器版本更旧的 JDBC 驱动程序可能会导致安全问题。

关于java - 可以使用 8.4 和 9.0 postgres( hibernate )库构建一个 .war 文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10191598/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com