当前位置: 首页 > 知识库问答 >
问题:

Spring数据Neo4j和Grails 3

宇文学博
2023-03-14

是否有人拥有使用GrailsV3的SpringDataNeo4j(3.3.0)并愿意共享配置?

我想让Web界面工作(按这里:如何启用neo4j webadmin时使用sping-data-neo4j?),但我有点失去了当试图找出什么应该去Application.groovy,作为Grails从GrailsAutoConfiguration扩展它,所示示例从Neo4jConfiguration扩展它。

共有1个答案

徐文斌
2023-03-14

将以下依赖项添加到build。格雷德尔

compile("org.springframework.data:spring-data-neo4j")
compile "org.neo4j.app:neo4j-server:2.1.5"
compile "org.neo4j.app:neo4j-server:2.1.5:static-web"

下面的资源文件进入conf/Spring

资源。xml

<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:util="http://www.springframework.org/schema/util"
    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-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">

    <context:spring-configured/>
    <context:annotation-config/>

    <util:map id="config">
        <entry key="remote_shell_enabled" value="true"/>
    </util:map>

    <neo4j:config storeDirectory="target/data/db" base-package="com.example"/>

    <neo4j:repositories base-package="com.example.repositories"/>

    <bean id="graphDbFactory" class="org.neo4j.graphdb.factory.GraphDatabaseFactory"/>

    <bean id="graphDbBuilder" factory-bean="graphDbFactory" factory-method="newEmbeddedDatabaseBuilder">
        <constructor-arg value="target/data/db"/>
    </bean>

    <bean id="graphDbBuilderFinal" factory-bean="graphDbBuilder" factory-method="setConfig">
        <constructor-arg ref="config"/>
    </bean>

    <bean id="graphDatabaseService" factory-bean="graphDbBuilderFinal" factory-method="newGraphDatabase"
    destroy-method="shutdown"/>

    <bean id="serverWrapper" class="org.neo4j.server.WrappingNeoServerBootstrapper" init-method="start"
        destroy-method="stop">
        <constructor-arg ref="graphDatabaseService"/>
    </bean>
</beans>

资源。groovy(我确信这可以从resources.xml中添加很多内容,但我不确定该怎么做):

import com.example.MyGraph;

// Place your Spring DSL code here
beans = {
    myGraph(MyGraph)

}

src/main/groovy/com/example/MyGraph。java

package com.example;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.data.neo4j.core.GraphDatabase;

@Configuration
public class MyGraph extends Neo4jConfiguration {

    @Autowired
    GraphDatabase graphDatabase;

}

我将Neo4J的域类放在src/main/groovy/com/example/domain中,存储库类放在src/main/groovy/com/example/repositories中。然后,Spring示例代码可以正常工作。当您运行grailsrun-app时,端口7474上提供了Neo4J的web服务器管理界面。

 类似资料:
  • 我试图编写一个返回大量数据(200个节点)的查询。节点非常简单: 我最初使用Spring Data Neo4j模板接口,但在返回大约100个节点后发现它非常慢。 所以,我的问题是:是否有一种方法可以提供标签作为Cypher查询的一部分,以防止需要再次查询每个节点?或者,除此之外,是否有一种方法可以为SDN提供一个包含标签和属性的并将其转换为POJO? 注意:我意识到SDN团队正在未来的版本中完全使

  • 我正在使用数据库和。现在,我想导入相当大的数据集,因此我研究了的批插入功能。 经过我的研究,我发现: 用于嵌入式数据库:http://docs.neo4j.org/chunked/stable/batchinsert.html以及使用它的Michael Hunger项目:https://github.com/jexp/batch-import/ REST批处理终结点:http://docs.neo

  • 我有与Spring data neo4j一起工作的Spring服务,我决定将Spring data neo4j从2.2更新到当前版本-3.1.4。释放。所以第一次我更新了neo4j,项目失败了,我更新了Spring版本,不同的版本有不同的例外。这个服务包括在我的前端,我叫它是从网络。所以我不知道什么是最佳配置???配置与maven。这里有pom.xml Spring配置文件 所以每次加载db例外,

  • 有没有人使用Java API使用GraphAware TimeTree处理Spring数据Neo4J,并能提供一个简单的示例?

  • 我正在使用: neo4j 2.0。1 我有一个具有属性名称的节点人员,我想用Lucene语法搜索该属性。我在我的存储库中使用findByNamelike方法,它非常适合像value*或*value或*etc这样的查询。 但是我需要这样的查询{A*TO D*}。我发现了一个弃用的方法findAllByQuery(名称,查询),用这个方法我可以实现我的需求。 > 我还注意到,如果我从cypher创建节

  • Neo4j 2.0。0已发布。所以我更新了neo4j版本2.0。0.M6到2.0。0.0发布。并尝试在我的网站中更新模型,但出现异常。 组织。springframework。刀。DataIntegrityViolationException:唯一属性类java。lang.String rankStatId rel:false idx:true被设置为重复值3073631_99 MY SDN版本是2