我正在尝试在SparkJava中使用下面的etcd框架
https://github.com/AdoHe/etcd4j
代码如下:
get("/hello",(request, response) -> {
String value;
try {
EtcdClient client = new EtcdClient(URI.create("http://127.0.0.1:2379"));
String key = "/message";
value = client.get(key);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return value;});但是,当我尝试访问url时,如下所示的http://localhost:4567/hello
我得到以下错误
HTTP ERROR: 500
Problem accessing /hello. Reason:
java.lang.NoSuchFieldError: INSTANCE
Powered by Jetty:// 9.3.6.v20151106这里我漏掉了什么?etcd工作当使用SparkJava ()函数作为独立项目时,但是不使用SparkJava,有没有可以使用main()函数的etcd客户端?
发布于 2016-09-15 21:36:57
我将其与以下Etcd客户端配合使用:
<dependency>
<groupId>org.mousio</groupId>
<artifactId>etcd4j</artifactId>
<version>2.12.0</version>
</dependency>代码如下:
private static String etcdGet(Request request, Response response) {
EtcdClient client = new EtcdClient(URI.create("http://<ip-address>:2379"));
String key = "/message";
try {
EtcdResponsePromise<EtcdKeysResponse> value;
value = client.get(key).send();
return value.get().getNode().getValue();
} catch (Exception e) {
System.out.println(e);
throw new RuntimeException(e);
}
}https://stackoverflow.com/questions/39346312
复制相似问题