2015-07-02 53 views
1

我遇到一個奇怪的問題。無法探索由嵌入式neo4j創建的數據庫

我使用嵌入式neo4j創建了一個數據庫,其路徑爲「/Users/bondwong/Documents/workspace/pamela/target/data/pamela.db」。

下面是Spring配置:

<bean id="graphDbBuilder" factory-bean="graphDbFactory" 
    factory-method="newEmbeddedDatabaseBuilder"> 
    <constructor-arg value="target/data/pamela.db" /> 
</bean> 

然後,我改變了這一行neo4j-server.properties的:

org.neo4j.server.database.location=/Users/bondwong/Documents/workspace/pamela/target/data/pamela.db 

在那之後,我用捲曲來測試我的系統,這表明所有很好。這裏是讓id爲9節點的結果: enter image description here

然而,當我啓動了服務器,並使用瀏覽器來查看數據,什麼也不顯示: enter image description here

這裏是位置,這是一樣的一個Spring XML配置文件中: enter image description here

這裏是:SYSINFO結果: enter image description here

這裏是叔他JUnit測試及其結果,顯示出它實際上插入數據:

package repositoryTest; 

import static org.junit.Assert.*; 

import java.util.HashMap; 

import org.junit.Test; 
import org.junit.runner.RunWith; 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.test.context.ContextConfiguration; 
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 
import org.springframework.transaction.annotation.Transactional; 

import com.bond.pamela.domain.Diary; 
import com.bond.pamela.domain.factory.DiaryFactory; 
import com.bond.pamela.persistence.DirayRepository; 

@RunWith(SpringJUnit4ClassRunner.class) 
@ContextConfiguration({ "/applicationContext.xml" }) 
public class DiaryRepositoryTest { 
    @Autowired 
    DirayRepository repository; 

    @Test 
    @Transactional 
    public void testSaveDiary() { 
     Diary diary = (Diary) DiaryFactory.getInstance().create(
       new HashMap<String, Object>()); 
     repository.save(diary); 

     Diary retrivedDiary = repository.findOne(diary.getGraphId()); 
     assertEquals(diary, retrivedDiary); 
    } 

} 

enter image description here

,我認爲它應該工作,有人知道什麼是錯的?以及如何解決它。謝謝!

+1

只有一個進程可以一次訪問數據庫。 Neo4j服務器甚至不應該啓動。 –

+0

什麼:sysinfo說關於數據庫? –

+0

@MichaelHunger你是說我應該關閉neo4j服務器嗎?但是我想看看數據,你有其他的想法嗎?我停止了tomcat,在那裏我的應用程序運行,並試圖離開neo4j服務器單獨打開,仍然沒有任何東西。 –

回答

0

您可以編寫Java代碼server extension

或使用WrappingBootstrapper暫且。 或者寧可用ServerControls from Neo4j-Harness進行測試

創建數據時,您確定您提交的事務是否正確?

Transaction tx = db.beginTx(); 
// create data 
tx.success(); 
tx.close(); 

或更好

try (Transaction tx = db.beginTx()) { 
    // create data 
    tx.success(); 
} 
+0

我們主要使用WrappingBootstrapper進行調試,但我發現它已被棄用,甚至在下一個版本中被刪除 - 是否有計劃向嵌入式服務器添加「查詢瀏覽器」或類似的東西,或者官方建議停止使用嵌入式模式? – bennyl

相關問題