RestEasy客户端所需的罐子 [英] Required jars for RestEasy Client
问题描述
我需要提供一个java REST客户端,它应该包含一个包中所有必需的jar。我选择RestEasy作为REST框架,因为服务器应用程序是在JBoss上完成的。
我到目前为止发现的几乎所有示例都使用应用程序容器环境,其中这些库是提供,因此在编译期间只需要Java EE API或使用Maven构建,因此依赖关系会自动解决,这可能是一个好主意和目前的标准方法,但出于项目相关的原因,我需要在一个lib文件夹,能够在构建期间包含一个可执行的jar。
所以我的问题是,这对于构建一个可以做某事的简单客户端来说是必要的像这样:
ResteasyClient client = new ResteasyClientBuilder()。build();
ResteasyWebTarget target = client.target(myURL).queryParam(param,
value);
Builder builder = target.request(MediaType.APPLICATION_JSON).header(user,abc);
调用调用= builder.buildGet();
MyResponseObject response = invocation.invoke(MyResponseObject .class);
最简单的方法是使用,如果需要的话。就像我说的那样,只有jackson2提供商可能就足够了。但是如果你做需要jaxb-prodiver,这就是它的样子
再次,包含在下载中
I need to provide a java REST client, which should contain all required jars in one bundle. I chose RestEasy as REST framwork, since the server application is done on a JBoss.
Nearly all examples I found so far use either an application container environment, where those libs are provided and thus only the Java EE API is needed during compile or are build with Maven and thus dependencies are resolved automatically, which maybe be a good idea and the current standard way to do it, but for project-related reasons I need the jars in a lib folder and be able to include during the build and wihtin an executable jar.
So my question is, which jars a necessary to build a simple client which can do something like that:
ResteasyClient client = new ResteasyClientBuilder().build();
ResteasyWebTarget target = client.target(myURL).queryParam("param",
"value");
Builder builder = target.request(MediaType.APPLICATION_JSON).header("user", "abc");
Invocation invocation = builder.buildGet();
MyResponseObject response = invocation.invoke(MyResponseObject .class);
The easiest way is to use Maven. The reason I say this, is that the main artifact you want is the resteasy-client
artifact, but this artifact has dependencies on other artifacts. If I create a new Maven project, add only this dependency
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.9.Final</version>
</dependency>
The project will pull in all this artifacts
But if you are not using Maven, You can download the entire resteasy package here. It comes with a lot more than what you'll need, but it will have all the jars you see in the image above, along with some other goodies like user guides, examples and such. Base on the image above, just get the jars you need. Make sure you download the final-all version. When you unzip it, all the jars should be in the lib
dir.
Another thing I might mention is that in order to unmarshal JSON representation into your Java classes, you might also need resteasy-jackson2-provider
. Doing the same as above, you will see these pulled in artifacts
Again, these are also include in the download. This will work in most cases, if you are using JAXB annotations (which could return XML or JSON), because of the pulled in artifact jackson-module-jaxb-annotations
, but that artifact doesn't support all JAXB annotations, so you might need to pull in the resteasy-jaxb-provider
, if need be. Again like I said, just the jackson2-provider may be enough. But in the case you do need the jaxb-prodiver, here's what it looks like
Again, included in the download
这篇关于RestEasy客户端所需的罐子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!