JAX-RS 2.0 change default implementation

杀马特。学长 韩版系。学妹 提交于 2019-11-29 03:04:40

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); 

Where JAXRS_DEFAULT_CLIENT_BUILDER_PROPERTY is "javax.ws.rs.client.ClientBuilder"

In turn, FactoryFinder looks

  • 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.

So, to use RESTEasy, you should create a file

META-INF/services/javax.ws.rs.client.ClientBuilder

with the text:

org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder

which is the class name of the RESTEasy ClientBuilder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!