Cineasts的错误Spring数据neo4j的例子

时间:2014-04-29 05:43:13

标签: java neo4j spring-data spring-data-neo4j

我将cineast maven项目导入eclipse,但我遇到了配置问题......

cvc-complex-type.4: Attribute 'base-package' must appear on element 'neo4j:config'

以下是出现此错误的配置文件。

的applicationContext.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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"
       xmlns:tx="http://www.springframework.org/schema/tx"
       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.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <context:annotation-config/>
    <context:component-scan base-package="org.neo4j.cineasts">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>

    <context:spring-configured/>

    <neo4j:config storeDirectory="target/data/graph.db"/>
    <neo4j:repositories base-package="org.neo4j.cineasts.repository"/>

    <!--neo4j:config graphDatabaseService="graphDatabaseService"/>
    <bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
        <constructor-arg value="http://localhost:7474"/>
    </bean-->

    <bean class="org.neo4j.cineasts.movieimport.MovieDbApiClient">
        <constructor-arg value="926d2a79e82920b62f03b1cb57e532e6"/>
    </bean>
    <bean class="org.neo4j.cineasts.movieimport.MovieDbLocalStorage">
        <constructor-arg value="data/json"/>
    </bean>

    <tx:annotation-driven mode="proxy"/>

</beans>

电影 - 测试 - context.xml中

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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"
       xmlns:tx="http://www.springframework.org/schema/tx"
       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.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <context:annotation-config/>
    <context:spring-configured/>
    <context:component-scan base-package="org.neo4j.cineasts"/>

    <neo4j:config graphDatabaseService="graphDatabaseService"/>
    <neo4j:repositories base-package="org.neo4j.cineasts.repository"/>

    <bean id="graphDatabaseService" class="org.neo4j.test.ImpermanentGraphDatabase" destroy-method="shutdown"/>

    <bean class="org.neo4j.cineasts.movieimport.MovieDbApiClient">
        <constructor-arg value="926d2a79e82920b62f03b1cb57e532e6"/>
    </bean>
    <bean class="org.neo4j.cineasts.movieimport.MovieDbLocalStorage">
        <constructor-arg value="data/json"/>
    </bean>
    <tx:annotation-driven mode="proxy"/>
</beans>

1 个答案:

答案 0 :(得分:1)

查看http://blog.neo4j.org/2014/03/spring-data-neo4j-progress-update-sdn-3.html

这实际上是早先在Stack上的一个重复问题,但是,如果您使用的是最新的SDN(而且我很确定您是),那么您需要包含以下内容: &#34;碱包&#34; neo4j:config和neo4j:repositories elements中的属性。

在上面的链接中,Michael Hunger解释了这一点,您可以清楚地看到这些属性的值应该是什么。

HTH