How can I use the webadmin interface with an embedded Neo4j 2.0 instance?

我的梦境 提交于 2019-12-05 09:59:46

WrappingNeoServerBootstrapper & GraphDatabaseAPI are deprecated, but there is no alternitve for now ... So you have to use them.

For you, this a sample code of my application, where webadmin is started with an embedded neo4j 2.0.1 server :

val graphdb = new GraphDatabaseFactory()
          .newEmbeddedDatabaseBuilder(DBPath)
          .loadPropertiesFromFile(neo4jPropertiesPath)
          .newGraphDatabase()
          .asInstanceOf[GraphDatabaseAPI}

val srv = new WrappingNeoServerBootstrapper(graphdb, config);
srv.start()

So you must cast your "graphDatabaseService" to "GraphDatabaseAPI". Sorry I don't khnow how to this with spring ... but you can do a wrapper of WrappingNeoServerBootstrapper with the good type.

Cheers

Took me longer than I care to admit to get this working. Please take a look at this pom for the dependencies, basically 2 includes for neo4j-server and 2 for Jersey. You also have to config the WrappingNeoServerBootstrapper (deprecated).

My POM excludes the CH.QOS logging stuff from Neo4J in favour of my own log configuration.

I've used Spring as well and have externalised most of the config. You can see that file here.

Once that little lot is done, simply access localhost on port 7474.

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

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

<bean id="graphDbBuilder" factory-bean="graphDbFactory" factory-method="newEmbeddedDatabaseBuilder">
    <constructor-arg value="${neo4j.datastore}"/>
</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>

So verified this on OSX; Just to be clear once you add the POM updates and the spring configuration, that is all you need to do. Then just browsing to localhost:7474 gives you your object graph.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!