我有一个关于 MIMEParsingException 的问题。 我将 Java EE 6 与 NetBeans 6.8 结合使用。我用 Java 编写了一个简单的 REST Web 服务来打印“hello world”,它运行良好。 然后我编写了一个 REST Web 服务客户端(Java 主类)来测试 REST:
公共(public)类 HelloWorldClient {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource service = client.resource(getBaseURI());
String xml = service.path("resources").path("helloworld").accept(MediaType.TEXT_XML).get(String.class);
System.out.println(xml);
}
private static URI getBaseURI() {
return UriBuilder.fromUri("http://localhost:8080/HelloWorldApplication").build();
}
它没有错误地符合要求,但是当我运行它时,它会在这一行抛出 MIMEParsingException : 客户端 client = Client.create(config);
线程“主”com.sun.jersey.spi.service.ServiceConfigurationError 中的异常:jersey-client-components:类 com.sun.jersey.multipart 的依赖类 org/jvnet/mimepull/MIMEParsingException。未找到实现提供程序类 java.lang.Object 的 impl.MultiPartReader。提供商实现被忽略。 在 com.sun.jersey.spi.service.ServiceFinder.fail(ServiceFinder.java:388) 在 com.sun.jersey.spi.service.ServiceFinder.access$200(ServiceFinder.java:144) 在 com.sun.jersey.spi.service.ServiceFinder$LazyClassIterator.next(ServiceFinder.java:595) 在 com.sun.jersey.spi.service.ServiceFinder$LazyClassIterator.next(ServiceFinder.java:571) 在 com.sun.jersey.spi.service.ServiceFinder.toClassArray(ServiceFinder.java:374) 在 com.sun.jersey.api.client.Client.(Client.java:167) 在 com.sun.jersey.api.client.Client.(Client.java:139) 在 com.sun.jersey.api.client.Client.create(Client.java:466) 在 helloWorld.client.HelloWorldClient.main(HelloWorldClient.java:29)
谁能解决这个问题?非常感谢。
最佳答案
您缺少一个 dependency :
Non-maven developers require:
关于java - REST 中的 MIMEParsingException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2975513/