【问题标题】:Neo4j configuration with a spring aplicationContext and an external neo4j server带有 spring aplicationContext 和外部 neo4j 服务器的 Neo4j 配置
【发布时间】:2016-12-31 17:20:28
【问题描述】:

我正在开发一个使用 Spring 和 Neo4j 作为数据库的 RESTful Web 服务。我在我的 Windows 7 系统上安装了 Neo4j 3.0.7。我能够在我的 Spring 配置中使用以下行开发 CRUD API:<neo4j:config storeDirectory="C:\demo.graphdb" base-package="test.model"/>

现在我想连接在localhost:7474 上运行但在部署 WAR 文件期间出现异常的现有 Neo4j 数据库:

Configuration problem: Unable to locate Spring NamespaceHandler for
XML schema namespace
[http://www.springframework.org/schema/data/neo4j] Offending resource:
ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]

我的整个 Spring applicationContext 是:

 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:context="http://www.springframework.org/schema/context"   xmlns:util="http://www.springframework.org/schema/util"     xmlns:mvc="http://www.springframework.org/schema/mvc"   xmlns:tx="http://www.springframework.org/schema/tx"     xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"  xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
                        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
                        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
                        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
                        http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd">

  <context:component-scan base-package="test.*" />  
  <context:property-placeholder location="classpath:spring.properties" ignore-unresolvable="true" />    
  <mvc:annotation-driven />
  <mvc:default-servlet-handler />

  <bean id="graphDataBaseService" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase" >         <constructor-arg index="0" value="http://localhost:7474" />
    <constructor-arg index="1" value="neo4j"/>
    <constructor-arg index="2" value="dubai@1234"/>
  </bean>

  <neo4j:config graphDataBaseService="graphDataBaseService" base-package="test.model" />
    <neo4j:repositories base-package="test.dao"/>
  </beans>

我正在使用:

  • Spring Data Neo4j 版本 4.1.6.RELEASE
  • Neo4j 版本 3.0.7
  • Spring WebMvc 版本 4.1.1.RELEASE

【问题讨论】:

    标签: spring-mvc neo4j spring-data-neo4j spring-data-neo4j-4 neo4j-ogm


    【解决方案1】:

    Spring Data Neo4j 4.x 不支持 XML 配置(这在 3.x -> 4.x 重写期间被删除)。

    http://docs.spring.io/spring-data/neo4j/docs/current/reference/html/#_java_based_bean_configuration

    【讨论】:

    • 感谢 frant.hartm 分享这些有价值的信息。现在我将尝试进一步使用基于 java 的 bean 配置,如果遇到任何问题,我会继续发布。再次非常感谢。
    猜你喜欢
    • 2017-11-22
    • 1970-01-01
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-09
    • 1970-01-01
    相关资源
    最近更新 更多