简体   繁体   English

Springboot+JPA(Hibernate)+Oracle AbstractMethodError 未定义或继承 isValid(int) 的实现

[英]Springboot+JPA(Hibernate)+Oracle AbstractMethodError not define or inherit an implementation of isValid(int)

  • JavaJDK 1.13 JavaJDK 1.13
  • Springboot 2.2.6弹簧靴 2.2.6
  • Spring Data JPA弹簧数据 JPA
  • Oracle 10g甲骨文 10g

I'm a beginner in using Spring boot, and when I tried running the demo program, it reported exceptions as such:我是使用 Spring boot 的初学者,当我尝试运行演示程序时,它报告了如下异常:
Caused by: java.lang.AbstractMethodError: Receiver class oracle.jdbc.driver.T4CConnection does not define or inherit an implementation of the resolved method 'abstract boolean isValid(int)' of interface java.sql.Connection.

I've tried many solutions on the web (like upgrade the driver to ojdbc7 or higher, while I've been using ojdbc8 from the begining, and even tried ojdbc8 and ojdbc10 downloading from the website of Oracle 19c, but no one worked).我在网上尝试了很多解决方案(例如将驱动程序升级到 ojdbc7 或更高版本,而我从一开始就使用 ojdbc8,甚至尝试从 Oracle 19c 网站下载 ojdbc8 和 ojdbc10,但都没有成功)。

Following @JensSchauder 's suggestions, I peeked into the class oracle.jdbc.driver.T4CConnection and found there was really no such method called boolean isValid(int) but boolean isValidLight(int) instead.按照@JensSchauder 的建议,我查看了oracle.jdbc.driver.T4CConnection类,发现确实没有这样的方法叫做boolean isValid(int)而是boolean isValidLight(int)

Here is the screenshoot:这是屏幕截图:
ScreenShoot Here, boolean isValidLight(int var1) ScreenShoot Here, boolean isValidLight(int var1)

Here list the ojdbcs I've tried:这里列出了我尝试过的 ojdbcs:

  • ojdbc8:12.2.0.1 ojdbc8:12.2.0.1
  • ojdbc7:12.1.0.2 ojdbc7:12.1.0.2
  • ojdbc8:19.3.0.0(in use) ojdbc8:19.3.0.0(使用中)
  • ojdbc10:19.3.0.0 ojdbc10:19.3.0.0

How should I suppose to fix this?我应该如何解决这个问题? Maybe give up Oracle?也许放弃甲骨文?

Thanks for all your tips.感谢您的所有提示。

Something is really fishy here.这里的东西真的很可疑。 The method Hikari is looking for was introduced in Java 1.6 so it should definitely be there with ojdbc8 . Hikari 正在寻找的方法是在 Java 1.6 中引入的,因此它绝对应该与ojdbc8一起ojdbc8

I'd try the following to better understand what is going on.我会尝试以下操作以更好地了解发生了什么。

  1. check that the dependency is actually properly downloaded.检查依赖项实际上是否已正确下载。
  2. find the Connection class in the IDE and inspect it if it has the isValid method or not.在 IDE 中找到Connection类并检查它是否具有isValid方法。 I strongly suspect it has.我强烈怀疑它有。
  3. add a break point to the line where Hikari is throwing the exception and check what kind of object it is inspecting.在 Hikari 抛出异常的行添加一个断点并检查它正在检查的对象类型。

This already might give enough hints to debug this, if not please update your questions with the information you found.这可能已经为调试提供了足够的提示,如果没有,请使用您找到的信息更新您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM