Reputation: 396
I am new to both Neo4j and Spring. I have tried to do my homework as well as I can - my most sincere apologies if there is a magical doc with all the answers I missed along the way.
The aim is to interact with a Neo4j database using spring-data-neo4j. I have followed the guide in Good Relationships to some success, but would like to move on from version 1.6.M02, used in the book.
Although it is not specified in the Maven repository for spring-data-neo4j 2.2.1, the version of Neo4j that is included by Maven is 1.8.1, which as far as I am aware is the correct version. This also pulls in the Spring framework (3.1.4) as it should. So pom.xml
looks like:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>yet</groupId>
<artifactId>another</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>cinecopy</name>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
</project>
So then we have the most simple test case possible:
@ContextConfiguration(locations = "classpath:testContext.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class SomeTest {
@Autowired
Neo4jTemplate template;
@Test
@Transactional
public void badNews() {
Person add = new Person();
add.setName("What.");
add = template.save(add);
}
}
Which refers to testContext.xml
:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/data/neo4j
http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd">
<context:annotation-config/>
<neo4j:config storeDirectory="target/config-test"/>
</beans>
This gives me (full trace):
Failed to load ApplicationContext [...]
Cannot load configuration class: org.springframework.data.neo4j.config.Neo4jConfiguration
I find this peculiar given that things seem to work fine with pom.xml
as:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>yet</groupId>
<artifactId>another</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>cinecopy</name>
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>1.6.M02</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
</project>
Any guidance would be greatly appreciated!
Upvotes: 0
Views: 785
Reputation: 396
For reference, pom.xml
after Michael's input (or this question - so much for claiming to have done my homework):
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>another</groupId>
<artifactId>cine</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>yetagain</name>
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>2.3.0.M1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-validation_1.0_spec</artifactId>
<version>1.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.3</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
</dependencies>
</project>
I did not, however, encounter the same "hanging" issue as Steve - but then so far all I've done is load ApplicationContext.
Upvotes: 1