0

I'm wondering how to set up two different neo4j server instances when using Spring Data, e.g. one for test and the other for production purposes. I have my production server instance running on default port (7474) and my test server instance running on port 7475. How can I define where my node/relationships entities should be stored (whether in test or production environment, in this case)? I was not able to find it in the docs. This was my beans file so far, running everything just out the box (when I just used a single neo4j server instance):

    <?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 -->

Thank you all in advance!

jarandaf
  • 4,297
  • 6
  • 38
  • 67

2 Answers2

1

If you're using maven, also consider maven profiles. Here's a good comparison between spring and maven profiles: maven profiles or spring profiles?

Community
  • 1
  • 1
tstorms
  • 4,941
  • 1
  • 25
  • 47
  • My question is how? For example, when using Spring Data with MongoDB I can set all Mongo properties in the Mongo template. So, for example, I could define some environment variable (e.g.: -Denvironment=test) that reads a certain property file depending on its value and sets up the mongo template properly. Is there any equivalent when dealing with Neo4j? – jarandaf Mar 26 '13 at 23:15
  • You can do it the same way you did it with MongoDB. See e.g. http://stackoverflow.com/questions/11874017/controlling-a-project-with-maven-and-spring-how-to-set-spring-config-file-using how you can use maven profiles to configure spring properties. You probably don't want to configure the Neo4jTemplate, but a GraphDatabaseService instead (like e.g. EmbeddedGraphDatabase) – tstorms Mar 27 '13 at 07:43
0

You can benefit from Spring environment abstraction or Spring profiles. They both allow environment-dependent configurations.

fbiville
  • 8,407
  • 7
  • 51
  • 79