2012-07-11 98 views
0

我開始學習neo4j DB。我的測試代碼如下:無法實例化neo4j

@Test 
public void persistedMovieShouldBeRetrievableFromGraphDb() { 
    GraphDatabaseService graphDB = new EmbeddedGraphDatabase("data/graph.db"); 
    registerShutdownHook(graphDB); 
    Transaction tx = graphDB.beginTx(); 
    try{ 
     Neo4jTemplate template = new Neo4jTemplate(graphDB); 
     Movie forrestGump = template.save(new Movie("Forrest Gump", 1994)); 
     Movie retrievedMovie = template.findOne(forrestGump.getId(), Movie.class); 
     assertEquals("Retrieved Movie matched persisted one", forrestGump, retrievedMovie); 
     assertEquals("retrieved movie title matches", "Forrest Gump", retrievedMovie.getTitle()); 
    } 
    finally{ 
     tx.finish(); 
    } 
} 

然而,它總是給一個例外:

java.lang.NoSuchMethodError: org.neo4j.kernel.impl.transaction.SpringTransactionManager.<init>(Lorg/neo4j/kernel/GraphDatabaseAPI;)V 
+0

我見過這個問題。在你的'pom.xml'你有neo4j聲明和spring-data-neo4j,對嗎? – Nicholas 2012-07-11 20:03:49

+0

@Nicholas我沒有pom.xml。我正在手動管理我的JAR。 – Batman 2012-07-22 18:27:02

+0

那麼你能告訴我們你有哪些JAR的spring-data-neo4j和neo4j-kernel? – Nicholas 2012-07-23 23:09:40

回答

0

我與謝霆鋒的建議,認爲這是最有可能是簡單的pom.xml配置問題達成一致。看看示例Spring Data Neo4j example projects,將聲明的依賴關係與項目進行比較。

-Andreas