Database Reference
In-Depth Information
ClassPathXmlApplicationContext(configs);
System.out.println("Spring Context Created");
//Get the Object of PersistNeo4JData from the
Spring Context.
PersistNeo4JData data = (PersistNeo4JData)
context.getBean("persistNeo4JData");
//Invoke addData() method to persist our neo4j
nodes and relationships.
data.addData();
}
}
And we are done !!! Now, in the next step, let's execute our code.
6. Open your console, browse the root directory of your project, that is, Spring-
Neo4j , and execute the following Maven commands:
mvn install
mvn exec:java -Dexec.cleanupDaemonThreads=false
-Dexec.mainClass="org.neo4j.spring.samples.MainClass"
Note
Suppress DEBUG logs generated by the Spring framework by adding a new file
Spring-Neo4j\src\main\resources\logback.xml . The content of this
new file should be similar to https://github.com/qos-ch/logback/blob/master/logback-ex-
amples/src/main/java/chapters/configuration/sample0.xml . Now change <root
level="debug"> to <root level="warn"> .
Wait for the successful execution and completion of the preceding Maven commands and
you will see that the data is persisted in your Neo4j database. To verify whether we have
successfully persisted the data, open your console and execute the following command to
open the Neo4j shell— $NEO4J_HOME/bin/neo4j-shell -path <path of
Database file where we created the initial data> —and execute the
following Cypher query:
Match (n)-[r]->(n1) return n.name as Artist,type(r) as
Relationship, n1.title as Movie;
Search WWH ::




Custom Search