-
问题描述:使用rest-assured框架时,运行报错java.lang.AbstractMethodError:
io.restassured.internal.RequestSpecificationImpl.invokeMethod -
环境:maven项目,testng-restassured,jdk1.8
-
解决思路
首先查看jdk1.8文档找到了AbstractMethodError的原因
public class AbstractMethodError
extends IncompatibleClassChangeError
Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled
继续查看了rest-assured的官方文档以及相应报错,以及相关的帖子,帖子链接为:
https://ask.csdn.net/questions/7339023?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522161977387516780262542447%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=161977387516780262542447&biz_id=4&utm_medium=distribute.pc_search_result.none-task-ask_topic-2~all~first_rank_v2~rank_v29-2-7339023.pc_search_result_hbase_insert&utm_term=rest_assured++java.lang.AbstractMethodError%3A+io.restassured.internal.RequestSpecificationImpl.invokeMethod
其中提到了groovy版本的问题,rest-assured4.3的版本匹配的groovy3以上的版本,而我的jdk为1.8。所以降低了rest-assured的版本为4.2,从而解决问题
另外也发现本地工程jar有冲突,删除
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
同样能解决问题