我想知道如何在使用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 -->
谢谢大家提前!
我的问题是如何?例如,在MongoDB中使用Spring Data时,我可以在Mongo模板中设置所有的Mongo属性。因此,例如,我可以定义一些环境变量(例如:-Denvironment = test),根据它的值读取某个属性文件并正确设置mongo模板。在处理Neo4j时是否有任何等价物? – jarandaf 2013-03-26 23:15:31
您可以像使用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