不支持major.minor版本51.0(无法加载类org.postgresql.Driver) [英] Unsupported major.minor version 51.0 (unable to load class org.postgresql.Driver)

查看:1244
本文介绍了不支持major.minor版本51.0(无法加载类org.postgresql.Driver)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用maven创建一个Web应用程序并将其部署在heroku上。一切都可以找到,但是当我调用一个使用postgresql-9.2-1002.jdbc4驱动程序的操作时,我得到:

  java.lang .UnsupportedClassVersionError:org / postgresql / Driver:不支持major.minor版本51.0(无法加载类org.postgresql.Driver)

我知道问题是我在我的开发环境中使用jdk 7,而在heroku上运行的版本较低(至少我认为是这样)。我的第一个问题是,为什么其他操作不会给出这个错误只有使用postqresql驱动程序的操作给出了这个问题,其余的应用程序工作正常?我做的另一件事是下载jdk 6,然后将其添加到我的项目构建路径,然后配置eclipse编译器符合性为1.6,但即使如此,我也有同样的问题。我该如何解决这个问题?

解决方案

解决方案是使用为JDK 6编译的数据库驱动程序的副本。 b

您的应用程序代码似乎没有解决问题,因为您的构建更改可行。 (特别是对合规性级别的更改,我认为向(常规)构建路径添加JDK不会产生任何影响。)



但当然,不会对数据库驱动程序产生任何影响......因为您没有编译它。






然而,根据下载页面,postgresql-9.2-1002.jdbc4应该与Java 6兼容作为7.所以,也许你已经从其他地方获得了JAR ......或者通过源代码编译Java 7目标。


$ b

UPDATE - 我可以确认下载站点上的JAR有一个Driver类,它的字节码版本是50.0而不是51.0。我建议你从那里下载并使用新的副本。


Created a web app using maven and deployed it on heroku. Everything works find but when I call a action that uses the postgresql-9.2-1002.jdbc4 driver I get:

java.lang.UnsupportedClassVersionError: org/postgresql/Driver : Unsupported major.minor version 51.0 (unable to load class org.postgresql.Driver)

I know that the problem is I'm using jdk 7 on my development environment and a lower version is running on heroku (at least I think so). My first question is, why does the other actions don't give this error only actions that uses postqresql driver gives this problem the rest of the app works just fine? The other thing I did was download jdk 6 and then added it to my project build path, then configure eclipse compiler compliance to 1.6 but even then I have the same problem. How can I solve this?

解决方案

The solution is to use a copy of the database driver that is compiled for JDK 6.

It seems that you are not getting the problem with your application code because your build changes worked. (Specifically the change to the compliance level. I don't think adding a JDK to the (regular) build path will make any difference.)

But of course, that won't make any difference for the database driver ... because you are not compiling that.


However, according to the download page, postgresql-9.2-1002.jdbc4 is supposed to be compatible with Java 6 as well as 7. So maybe you've gotten the JAR from somewhere else ... or by compiling from source with a Java 7 target.

UPDATE - I can confirm that the JAR on the download site has a Driver class whose bytecode version is 50.0 not 51.0. I suggest you download and use a fresh copy from there.

这篇关于不支持major.minor版本51.0(无法加载类org.postgresql.Driver)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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