我正在尝试用下面的代码运行我的第一个Restlet服务器:
import org.restlet.Server;
import org.restlet.data.Protocol;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
public class WebServer extends ServerResource {
/**
* @param args
* @throws Exception
*/
public WebServer() throws Exception {
// Create the HTTP server and listen on port 8182
Server server = new Server(Protocol.HTTP, 8182, WebServer.class);
server.start();
}
@Get
public String present() {
return "hello, world";
}
}但是当我启动服务器时,我收到了这个错误消息:
No available server connector supports the required protocols: 'HTTP' . Please add the JAR of a matching connector to your classpath. Then, register this connector helper manually.
我将"org.restlet.jar“复制到\libs文件夹,并将JAR添加到Libraries in Java Build Path中。我该怎么办?怎么啦?
发布于 2015-02-15 02:15:25
如果您将其配置为使用NIO HttpServerHelper,则可以运行它。只需下载NIO扩展并在RestLet引擎中对其进行配置,就可以再次启动服务器。(在2.3.1上测试)。
import org.restlet.ext.nio.HttpServerHelper;
...
Engine.getInstance().getRegisteredServers().clear();
Engine.getInstance().getRegisteredServers().add(new HttpServerHelper(null));要查看NIO扩展是否适用于您的版本,您可以查看:http://restlet.com/technical-resources/restlet-framework/guide/2.3/extensions/editions-matrix
https://stackoverflow.com/questions/25483312
复制相似问题