【问题标题】:Cannot load Neo4jConfiguration with spring-data-neo4j 2.2.1无法使用 spring-data-neo4j 2.2.1 加载 Neo4jConfiguration
【发布时间】:2013-06-10 15:48:36
【问题描述】:

我是 Neo4j 和 Spring 的新手。我已经尽我所能做我的功课——如果有一个神奇的文档,我在此过程中错过了所有的答案,我最诚挚的歉意。

目的是使用 spring-data-neo4j 与 Neo4j 数据库进行交互。我已经按照良好关系中的指南取得了一些成功,但想从书中使用的 1.6.M02 版本继续前进。

虽然在 spring-data-neo4j 2.2.1 的 Maven 存储库中不是 specified,但 Maven 包含的 Neo4j 版本是 1.8.1,据我所知是正确的版本。这也按应有的方式引入了 Spring 框架(3.1.4)。所以pom.xml 看起来像:

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

那么我们就有了最简单的测试用例:

@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);

    }

}

指的是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>

这给了我 (full trace):

Failed to load ApplicationContext [...]
Cannot load configuration class: org.springframework.data.neo4j.config.Neo4jConfiguration

我觉得这很奇怪,因为 pom.xml 似乎可以正常工作:

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

任何指导将不胜感激!

【问题讨论】:

  • 使用新发布的 2.3.0.M1 兼容 Neo4j 1.9
  • 请确保你的 pom.xml 中有 cglib(这就是它所抱怨的)cglibcglib 2.2.2
  • 谢谢,Michael - 我之前看到它抱怨 cglib,但包含 3.0。适用于 2.2 和 2.3.0.M1/1.9。感谢您的所有工作!

标签: neo4j spring-data-neo4j


【解决方案1】:

供参考,pom.xml 在 Michael 的输入之后(或 this question - 声称已经完成了我的作业):

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

然而,我没有遇到与 Steve 相同的“挂起”问题 - 但到目前为止,我所做的只是加载 ApplicationContext。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多