0

Hi, I am trying to run a query using the following :

final GraphDatabaseService graphDatabaseService = new EmbeddedGraphDatabase("http://localhost:7474/db/data");
ExecutionEngine engine = new ExecutionEngine(graphDatabaseService,StringLogger.DEV_NULL);
ExecutionResult result = engine.execute("START n=node(0) RETURN n");

However, an exception is fired upon executiong the upon code :

Exception in thread "main" java.lang.NoClassDefFoundError: scala/Function0

Can you give me advises on how to solve this issue, anyone ever had the same one ?

Thanks.

4

1 回答 1

0
<dependency>
  <groupId>org.neo4j</groupId>
  <artifactId>neo4j-rest-graphdb</artifactId>
  <version>1.9.M04</version>
</dependency>

然后在你的java代码中使用它,如下所示:

import org.neo4j.rest.graphdb.RestAPI;
import org.neo4j.rest.graphdb.RestAPIFacade;
import org.neo4j.rest.graphdb.query.RestCypherQueryEngine;
import org.neo4j.rest.graphdb.util.QueryResult;

import java.util.Map;

import static org.neo4j.helpers.collection.MapUtil.map;

public class RestApiTest {
    public static void main(String[] args) {
        final RestAPI api = new RestAPIFacade("http://localhost:7474/db/data");
        final RestCypherQueryEngine engine = new RestCypherQueryEngine(api);
        final QueryResult<Map<String,Object>> result = engine.query("start n=node({id}) return n.name, id(n) as id", map("id", 0));
        for (Map<String, Object> row : result) {
            long id=((Number)row.get("id")).longValue();
            String name= (String) row.get("n.name");
        }
    }
}
于 2013-04-09T07:16:21.277 回答