0
我正在嘗試創建嵌入式HighlyAvailableGraphDatabase。我的服務器配置,Neo4j嵌入式HighlyAvailableGraphDatabase
ha.server_id=1
ha.initial_hosts=192.168.9.1:5001,192.168.9.2:5002,192.168.9.3:5003
ha.server=192.168.9.1:6002
ha.cluster_server=192.168.9.1:5001
ha.server_id=2
ha.initial_hosts=192.168.9.1:5001,192.168.9.2:5002,192.168.9.3:5003
ha.server=192.168.9.2:6002
ha.cluster_server=192.168.9.2:5002
ha.server_id=3
ha.initial_hosts=192.168.9.1:5001,192.168.9.2:5002,192.168.9.3:5003
ha.server=192.168.9.3:6002
ha.cluster_server=192.168.9.3:5003
在我的java類,我創建數據庫如下,
public class HighAvailableDbTest
{
private static GraphDatabaseService graphDb;
private static Map<String, String> haConfig = new HashMap<String, String>();
public static void main(String a[])
{
HighlyAvailableGraphDatabaseFactory databaseFactory = new HighlyAvailableGraphDatabaseFactory();
haConfig.put("org.neo4j.server.database.mode", "HA");
haConfig.put("org.neo4j.server.webserver.address","0.0.0.0");
haConfig.put("CONFIG_KEY_HA_MACHINE_ID","1");
haConfig.put("CONFIG_KEY_HA_SERVER", "192.168.9.1:6002");
graphDb = new HighlyAvailableGraphDatabaseFactory()
.newHighlyAvailableDatabaseBuilder("test.db")
.setConfig(haConfig)
.newGraphDatabase();
}
}
但是當我運行的代碼,我得到以下異常:
Exception in thread "main" java.lang.NoSuchFieldError: indexProviders
at org.neo4j.graphdb.factory.HighlyAvailableGraphDatabaseFactory$1.newDatabase(HighlyAvailableGraphDatabaseFactory.java:47)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:197).
幫我!!。 在此先感謝。
聽起來像在你的Java類路徑中的版本衝突。請檢查您是否只配置了單個版本的neo4j庫。 (例如,mvn依賴項:樹) –
您可以調用HighlyAvailableGraphDatabaseFactory的構造函數兩次。這也可能會導致一些問題。 – Jotschi