在嵌入式Neo4j中使用Neo4j浏览器
生活随笔
收集整理的這篇文章主要介紹了
在嵌入式Neo4j中使用Neo4j浏览器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
有時候,您有一個應用程序以嵌入式模式使用Neo4j,但還需要使用Neo4j Web瀏覽器來處理圖形。 由于一次最多只能從一個進程訪問數據庫,因此在嵌入式Neo4j應用程序運行時嘗試啟動Neo4j服務器將無法工作。
WrappingNeoServerBootstrapper盡管已被棄用,但仍可以解決。
設置方法如下。
1.確保您具有這些Maven依賴項
<dependency><groupId>org.neo4j</groupId><artifactId>neo4j</artifactId><version>2.1.5</version> </dependency> <dependency><groupId>org.neo4j.app</groupId><artifactId>neo4j-server</artifactId><version>2.1.5</version> </dependency> <dependency><groupId>org.neo4j.app</groupId><artifactId>neo4j-server</artifactId><version>2.1.5</version><classifier>static-web</classifier> </dependency>2.啟動WrappingNeoServerBootstrapper
public static void connectAndStartBootstrapper() {WrappingNeoServerBootstrapper neoServerBootstrapper;GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder("/path/to/db").newGraphDatabase();registerShutdownHook(db);try {GraphDatabaseAPI api = (GraphDatabaseAPI) db;ServerConfigurator config = new ServerConfigurator(api);config.configuration().addProperty(Configurator.WEBSERVER_ADDRESS_PROPERTY_KEY, "127.0.0.1");config.configuration().addProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, "7575");neoServerBootstrapper = new WrappingNeoServerBootstrapper(api, config);neoServerBootstrapper.start();catch(Exception e) {//handle appropriately} } 這里發生兩件事-GraphDatabaseService準備在嵌入式模式下使用,Neo4j Web瀏覽器可用于http://127.0.0.1:7575/
您無需一起啟動它們,而是根據需要啟動和停止WrappingNeoServerBootstrapper,只需要擁有GraphDatabaseService的句柄即可。
再次注意,不建議使用WrappingNeoServerBootstrapper。 在編寫本文時,此代碼適用于2.1.5,但不能為Neo4j的將來版本提供任何保證。
翻譯自: https://www.javacodegeeks.com/2014/11/using-the-neo4j-browser-with-embedded-neo4j.html
總結
以上是生活随笔為你收集整理的在嵌入式Neo4j中使用Neo4j浏览器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为Mate60 Pro+上架华为商城!
- 下一篇: 浏览器中的JavaFX