2

我在 GWT 中使用 Restlet 开发了一个简单的 hello world 应用程序,但它让我失望了

“没有可用的客户端连接器支持所需的协议:'HTTP'”在客户端和服务器端

“没有可用的服务器连接器支持所需的协议:'HTTP'。请将匹配连接器的 JAR 添加到您的类路径中。”

这是我的 hello world 应用程序:

客户:

import org.restlet.resource.ClientResource;

public class HelloClient {

    public static void main(String[] args) throws Exception {
        ClientResource helloClientresource = new ClientResource(
                "http://localhost:8111/");
        helloClientresource.get().write(System.out);
    }
}

服务器资源:

import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

/**
 * Simple "hello, world" server resource.
 */
public class HelloServerResource extends ServerResource {

    @Get("txt")
    public String represent() {
        return "hello, world";
    }
}

服务器:

import org.restlet.Server;
import org.restlet.data.Protocol;
public class HelloServer {

    public static void main(String[] args) throws Exception {
        Server helloServer = new Server(Protocol.HTTP, 8111,
                HelloServerResource.class);
        helloServer.start();
    }

}
4

1 回答 1

1

“没有可用的服务器连接器支持所需的协议:'HTTP'。请将匹配连接器的 JAR 添加到您的类路径”

确保已将相关的 jar 文件添加到类路径中:例如:GWT 客户端仅依赖于 GWT 版本中提供的核心 Restlet JAR (org.restlet.jar)。另请参阅常见问题解答:对于最小的应用程序,我的类路径中必须包含哪些 JAR 文件?并查看此处给出的答案:没有可用的客户端连接器支持所需的协议:'HTTP'

于 2012-01-21T15:45:52.323 回答