Question

I am new with Neo4j. I would like to run correctly the examples provided. Actually even if Spring test run without error when i try to see what is in the graph DB (with Neo4j server standalone install) there is nothing inside so i'm wondering why :/

here is my config (original config of example actually except versions) :

Pom.xml

<properties>
    <spring.version>3.2.8.RELEASE</spring.version>
    <spring-data-neo4j.version>3.0.2.RELEASE</spring-data-neo4j.version>
    <neo4j.version>2.0.1</neo4j.version>
    ...
</properties>
<dependencies>
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j-rest</artifactId>
    <version>${spring-data-neo4j.version}</version>
</dependency>
<!-- SDN for simple mapping mode -->
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j</artifactId>
    <version>${spring-data-neo4j.version}</version>
</dependency>
    <dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-kernel</artifactId>
    <version>${neo4j.version}</version>
    <type>test-jar</type>
    <scope>test</scope>
</dependency>

And my spring context :

<context:spring-configured />
<context:annotation-config />
<context:component-scan base-package="org.springframework.data.neo4j.examples.hellograph" />

<neo4j:config storeDirectory="target/neo4j-db-plain" base-package="org.springframework.data.neo4j.examples.hellograph.domain" />

<neo4j:repositories base-package="org.springframework.data.neo4j.examples.hellograph.repositories" />

<tx:annotation-driven />

Thank you very much !

Was it helpful?

Solution

It doesn't look like you've named a graph database bean at all here. I'm not too familiar with the "storeDirectory" attribute, but, here's a sample config I've used with SDN:

<!-- neo4j setup -->
    <neo4j:repositories base-package="com.domain.project.repositories"/>

    <bean id="graphDatabaseService"
        class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
        <constructor-arg index="0" value="http://hostname:7474/db/data" />  
    </bean>

    <neo4j:config base-package="com.domain.project.entities" graphDatabaseService="graphDatabaseService"/>

The above is for using Neo4j in (remote) server mode via REST, and so you'll likely have to change the graphDatabaseService bean if you're planning on doing this in embedded mode. Something like:

<bean id="graphDbFactory" class="org.neo4j.graphdb.factory.GraphDatabaseFactory"/>
<bean id="graphDatabaseService" scope="singleton" destroy-method="shutdown"
      factory-bean="graphDbFactory" factory-method="newEmbeddedDatabase">
    <constructor-arg value="target/config-test"/>
</bean>

<neo4j:config graphDatabaseService="graphDatabaseService" base-package="org.example.domain"/>

http://docs.spring.io/spring-data/data-neo4j/docs/3.1.x/reference/html/setup.html is jam-packed with good info on this.

HTH

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top