我已经创建了一个运行 Neo4j(社区 AMI)的 AWS EC2 实例,并且我已通过浏览器成功连接到端点。现在我想通过 Restbinding 从 java 应用程序访问我的数据库
`RestAPI graphDB = new RestAPIFacade("EC2_ENDPOINT:7474/db/data/");
QueryEngine engine=new RestCypherQueryEngine(graphDB);
QueryResult<Map<String,Object>> result = engine.query("start n=node(*) return count(n) as total", Collections.EMPTY_MAP);
Iterator<Map<String, Object>> iterator=result.iterator();
if(iterator.hasNext()) {
Map<String,Object> row= iterator.next();
System.out.print("Total nodes: " + row.get("total")); `
我已经为本地主机测试了这段代码并得到了结果,但是当我尝试这个时,出现了这个异常!
Exception in thread "main" java.lang.RuntimeException: Error reading as JSON '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /db/data/cypher. Reason:
<pre> Not Found</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
任何人都可以帮助我吗? 谢谢
最佳答案
您可以使用 http://EC2_ENDPOINT:7474/db/data/ 手动访问数据库吗? ?
您是否在 AWS 安全配置中打开了端口。您是否在 conf/neo4j-server.properties
中配置 Neo4j 服务器以监听公共(public)接口(interface)?
关于java - 使用 java Rest Binding 在 aws 实例上使用 Neo4j,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28583710/