当发送带有消费者密钥和机密的放心请求时,引发scribejava NoClassDefFoundError

问题描述 投票:0回答:1

这是我的邮递员要求的屏幕截图。enter image description here

我在pom.xml中具有以下依赖项

   <dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>3.0.6</version>
    <scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <version>1.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20180813</version>
</dependency>
 <!-- https://mvnrepository.com/artifact/org.scribe/scribe -->
        <dependency>
            <groupId>org.scribe</groupId>
            <artifactId>scribe</artifactId>
            <version>1.3.7</version>
        </dependency>

这是我放心的Java代码。

@Test
        public void token() {
            String myconsumerKey="demokey";
            String myconsumerSecret="demoObject";
             JSONObject jsonObj = new JSONObject()
                    .put("ProfileName","demoProdile")
                    .put("Count",1);

            String uri="https://demo.com/";
            Response res = (Response) given()
                    .header("Content-Type", "application/json")
                    .auth().oauth("consumerKey",myconsumerKey,
                            "consumerSecret",myconsumerSecret)
                    .body(jsonObj.toString()).when().post(uri);
    }

但是,它引发java.lang.NoClassDefFoundError:com / github / scribejava / core / builder / api / DefaultApi10a

我在这里检查了几个答案,但找不到任何可行的解决方案。预先感谢。

java rest-assured
1个回答
0
投票

似乎ScribeJava最新版本中已弃用AbstractRequest,我降级为2.5.3,并且不再看到

com / github / scribejava / core / model / AbstractRequest

<dependency>
    <groupId>com.github.scribejava</groupId>
    <artifactId>scribejava-apis</artifactId>
    <version>2.5.3</version>
</dependency>
© www.soinside.com 2019 - 2024. All rights reserved.