JAX-RS 2.0更改默认实现 [英] JAX-RS 2.0 change default implementation
问题描述
我正在尝试将RESTEasy用作JAX-RS 2.0客户端实现.问题是我遇到了运行时异常:
I'm trying to use RESTEasy as JAX-RS 2.0 client implementation. The problem is that I got runtime exception:
06-28 13:29:06.410: E/AndroidRuntime(5745): Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder
06-28 13:29:06.410: E/AndroidRuntime(5745): at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:103)
因此,如果我理解正确的话,newBuilder()
方法将搜索JerseyClientBuilder
.如何告诉系统改用RESTEasy?
So the newBuilder()
method is searching for JerseyClientBuilder
if I understand it correct. How can I tell the system to use RESTEasy instead?
推荐答案
JAX-RS依赖于服务提供者约定.
在newBuilder
方法的第一行中,您可以阅读:
Well, JAX-RS relies on the Service Provider convention.
On the first lines of the newBuilder
method you can read:
Object delegate = FactoryFinder.find(JAXRS_DEFAULT_CLIENT_BUILDER_PROPERTY,
JAXRS_DEFAULT_CLIENT_BUILDER);
JAXRS_DEFAULT_CLIENT_BUILDER_PROPERTY
是"javax.ws.rs.client.ClientBuilder"
FactoryFinder
看上去
- 首先将类名放入
META-INF/services/javax.ws.rs.client.ClientBuilder
- 然后在属性
javax.ws.rs.client.ClientBuilder
中将其插入${java.home}/lib/jaxrs.properties
- 最后进入系统属性
javax.ws.rs.client.ClientBuilder
.
- first for the class name into
META-INF/services/javax.ws.rs.client.ClientBuilder
- then in the property
javax.ws.rs.client.ClientBuilder
into${java.home}/lib/jaxrs.properties
- finally into the System property
javax.ws.rs.client.ClientBuilder
.
因此,要使用RESTEasy,您应该创建一个文件
So, to use RESTEasy, you should create a file
META-INF/services/javax.ws.rs.client.ClientBuilder
带有文字:
org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder
这是RESTEasy ClientBuilder
的类名
which is the class name of the RESTEasy ClientBuilder
这篇关于JAX-RS 2.0更改默认实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!