没有可用的客户端连接器支持所需的协议:“HTTP" [英] No available client connector supports the required protocol: 'HTTP'

查看:45
本文介绍了没有可用的客户端连接器支持所需的协议:“HTTP"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.我正在使用 Restlet 框架,当我运行以下代码获取和异常内部连接器错误 (1002) - 没有可用的客户端连接器支持所需的协议:'HTTP'.

Greeting. I am playing with Restlet framework, when I am running following code getting and exception Internal Connector Error (1002) - No available client connector supports the required protocol: 'HTTP'.

ClientResource cr = new ClientResource(
"http://127.0.0.1:8888/user/123");
UserResource resource = cr.wrap(UserResource.class);
User user = new User();
user.setName("xxx");
user.setPassword("xxx");
UserValidation userValidation = resource.retrieve(user);
if (userValidation != null) {
  System.out.println("Welcome, User");
} else {
  System.out.println("Not a vliad user");
}

这里有人试过 Retlet 吗?可以指导我正确的方向吗?或者可以重定向到有用的教程?

Is there anybody here tried the Retlet before? Can guide me to proper direction? Or can redirect to helpfull tutorial?

推荐答案

Restlet 依赖于连接器"来实现客户端和服务器.它们有点像插件,因为它们是模块化的,您可以轻松选择使用哪个.在运行时,Restlet 检查类路径以查看哪些连接器可用,并加载它们.每个连接器都打包在 1 个用于连接器本身的 JAR 文件中,以及用于依赖项的 N 个文件.因此,您只需将相关的 JAR 添加到类路径中,就可以使连接器可用于框架.

Restlet depends on "connectors" to implement clients and servers. They're kind of like plugins, in that they're modular, and you can easily choose which to use. At runtime, Restlet checks the classpath to see which connectors are available, and loads them. Each connector is packaged in 1 JAR file for the connector itself plus N files for dependencies. So you can make a connector available to the framework by simply adding the relevant JARs to the classpath.

您必须使用 Restlet 1.0 或 1.1,因为 2.0 包括简单的内置 HTTP 客户端和服务器连接器.建议你升级到2.0;由于单个 JAR 包含框架、引擎和内置连接器,因此开发起来要容易得多;使用 1.1,有时您可能需要 6-7 个 JAR 来测试一个简单的应用程序.

You must be using Restlet 1.0 or 1.1, because 2.0 includes simple built-in HTTP client and server connectors. I suggest you upgrade to 2.0; it's a lot easier to develop with because a single JAR contains the framework, engine, and the built-in connectors; with 1.1 you can sometimes need 6-7 JARs just to test a simple app.

这篇关于没有可用的客户端连接器支持所需的协议:“HTTP"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆