我一直在尝试java
使用以下代码将数据放入弹性搜索中:
String url = "http://localhost:9200/testindex2/test/2";
HttpClient client = new DefaultHttpClient();
HttpPut put = new HttpPut(url);
JSONObject json = new JSONObject();
json.put("email", "abc@abof.com");
json.put("first_name", "abc");
StringEntity se = new StringEntity("JSON: " + json.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"Text"));
put.setEntity(se);
HttpResponse response = client.execute(put);
System.out.println("\nSending 'PUT' request to URL : " + url);
System.out.println("Put parameters : " + put.getEntity());
System.out.println("Response Code : " + response.getStatusLine().getStatusCode());
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = …
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
package com.mongoDB;
import spark.Spark;
public class HelloWorldSparkStyle {
public static void main(String[] args) {
Spark.get("/hello", (req, res) -> "Hello World");
}
}
Run Code Online (Sandbox Code Playgroud)
当我通过main方法运行它时运行正常但在我尝试编译时抛出以下错误:
\HelloWorldSparkStyle.java:[9,33] error: lambda expressions are not supported in -source 1.5
D:\WorkspaceWithJava8\BeginnerProject>javac -version
javac 1.8.0_60
Run Code Online (Sandbox Code Playgroud)
我正在使用Eclipse IDE并尝试通过命令行编译它.