Spring 数据 Neo4j 和 Grails 3
Spring Data Neo4j and Grails 3
是否有人拥有 Spring Data Neo4j (3.3.0) 与 Grails v3 一起使用并且愿意分享配置?
我想让 Web 界面正常工作(按照此处:),但在尝试确定 Application.groovy
中应该包含哪些内容时我有点迷路了,因为 Grails 从 GrailsAutoConfiguration
扩展它,而显示的示例从 Neo4jConfiguration
.
扩展它
将以下依赖项添加到 build.gradle
:
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
。
resources.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>
resources.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 示例代码可以正常工作。当您 运行 grails run-app
.
时,端口 7474 上有一个 Neo4J 的 Web 服务器管理界面可用
是否有人拥有 Spring Data Neo4j (3.3.0) 与 Grails v3 一起使用并且愿意分享配置?
我想让 Web 界面正常工作(按照此处:Application.groovy
中应该包含哪些内容时我有点迷路了,因为 Grails 从 GrailsAutoConfiguration
扩展它,而显示的示例从 Neo4jConfiguration
.
将以下依赖项添加到 build.gradle
:
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
。
resources.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>
resources.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 示例代码可以正常工作。当您 运行 grails run-app
.