gpt4 book ai didi

java - 线程中的异常 "main"java.lang.NoSuchMethodError : org. jboss.resteasy.util.CaseInsensitiveMap.add(Ljava/lang/String;Ljava/lang/Object;)V

转载 作者:行者123 更新时间:2023-12-02 04:42:55 26 4
gpt4 key购买 nike

我是 RestEasy Web 服务的新手。我从 RestEasy Web-Serivce 得到了正确的响应,但是当我尝试编写 Web 服务客户端时,出现了上述错误。请找到如下代码。请让我知道问题出在哪里。我正在使用 RestEasy 3.0.9 Final。

RestServiceClient.java

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;

public class RestServiceClient {

public static void main(String[] args) throws Exception {
Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target("http://localhost:8888/RestSpring/rest/response/hello");
Response response = target.request().get();
String value = response.readEntity(String.class);
System.out.println("Response Value : "+value);
response.close();
}

}

Pom.xml

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java-version>1.7</java-version>
<spring.version>4.0.5.RELEASE</spring.version>
<resteasy.version>3.0.9.Final</resteasy.version>
<jax.rs.version>2.0</jax.rs.version>
<javax.servlet.version>3.1.0</javax.servlet.version>
<jackson.version>1.9.4</jackson.version>
</properties>


<dependencies>
<!-- Spring Framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>

<!-- RestEasy -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>${resteasy.version}</version>
</dependency>

<!-- RestEasy Spring Integration -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-spring</artifactId>
<version>${resteasy.version}</version>
</dependency>

<!-- restEasy for file upload -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>2.2.0.GA</version>
</dependency>

<!-- RestEasy Jackson Json Mapper -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>${resteasy.version}</version>
</dependency>

<!-- JAX-RS -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${jax.rs.version}</version>
</dependency>

<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>

<!-- Log4j Jar -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

<!-- Apache Common Lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>

<!-- Junit and Mockito -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<!-- RestEasy Client -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.2.Final</version>
</dependency>

</dependencies>

RestService.java

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.jboss.resteasy.annotations.providers.multipart.MultipartForm;
import org.springframework.stereotype.Controller;

import com.web.app.rest.object.Employee;
import com.web.app.rest.object.FileUploadForm;

@Controller
@Path("/response")
public class RestService {

@GET
@Path("/hello")
public String sayHelloRestEasy(){
System.out.println("Calling web!");
return "RestEasy say Hello user!!!";


}
}

最佳答案

尝试使用相应版本的resteasy-multipart-provider:

<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>${resteasy.version}</version>
</dependency>

2.2.0似乎很老了

关于java - 线程中的异常 "main"java.lang.NoSuchMethodError : org. jboss.resteasy.util.CaseInsensitiveMap.add(Ljava/lang/String;Ljava/lang/Object;)V,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29963880/

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