2013-03-24 78 views
0

我想知道如何在使用Spring數據時設置兩個不同的neo4j服務器實例,例如一個用於測試,另一個用於生產目的。我的生產服務器實例在默認端口(7474)上運行,我的測試服務器實例在端口7475上運行。如何定義我的節點/關係實體應存儲在哪裏(無論是在測試環境還是生產環境中)?我無法在文檔中找到它。這是我的豆子文件,到目前爲止,運行一切都只是開箱時(我只用一個單一的Neo4j服務器實例):多個neo4j實例配置

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:context="http://www.springframework.org/schema/context" 
      xmlns:mongo="http://www.springframework.org/schema/data/mongo" 
      xmlns:neo4j="http://www.springframework.org/schema/data/neo4j" 
      xsi:schemaLocation= 
      "http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-3.0.xsd 
      http://www.springframework.org/schema/data/mongo 
      http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd 
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
      http://www.springframework.org/schema/data/neo4j 
      http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd"> 

    <!-- Neo4j --> 
    <neo4j:config storeDirectory="data/graph.db"/> 
    <neo4j:repositories base-package="repositories.neo4j"/> 

    <!-- some more stuff --> 

謝謝大家提前!

回答

1

如果您使用的是maven,還可以考慮maven配置文件。這裏有一個很好的比較春季和maven配置文件:maven profiles or spring profiles?

+0

我的問題是如何?例如,在MongoDB中使用Spring Data時,我可以在Mongo模板中設置所有的Mongo屬性。因此,例如,我可以定義一些環境變量(例如:-Denvironment = test),根據它的值讀取某個屬性文件並正確設置mongo模板。在處理Neo4j時是否有任何等價物? – jarandaf 2013-03-26 23:15:31

+0

您可以像使用MongoDB一樣進行操作。見例如http://stackoverflow.com/questions/11874017/controlling-a-project-with-maven-and-spring-how-to-set-spring-config-file-using--如何使用maven配置文件來配置彈簧屬性。您可能不想配置Neo4jTemplate,而是使用GraphDatabaseService(例如EmbeddedGraphDatabase) – tstorms 2013-03-27 07:43:38