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

使用spring-data-neo4j时如何启用neo4j webadmin?

鞠源
2023-03-14

我无融资创业新项目访问Neo4j数据与REST的例子。该示例使用嵌入式数据库,而不是独立的neo4j服务器,但我希望使用Neo4J webadmin界面来可视化我的数据。如何从此配置开始启用webadmin接口?

(他们让WrappingNoServerBootstrapper与spring-data-neo4j一起使用WrappingNoServerBootstrapper,但答案中遗漏了很多知识,例如,甚至没有提到配置的位置。由于对POMs来说是新手,因此spring Boot和neo4j我无法使用该答案。)

共有1个答案

西门品
2023-03-14

您正在使用的示例需要进行一些调整以启用Neo4j浏览器。我从一个不同的例子开始,用Neo4j访问数据的例子,效果很好。

您需要执行以下操作:

>

  • 将spring boot pom上的版本更改为1.2。1.发布:

     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>1.2.1.RELEASE</version>
     </parent>
    

    添加Neo4jServer的依赖项:

    <dependency>
        <groupId>org.neo4j.app</groupId>
        <artifactId>neo4j-server</artifactId>
        <version>2.1.5</version>
    </dependency>
    <dependency>
        <groupId>org.neo4j.app</groupId>
        <artifactId>neo4j-server</artifactId>
        <version>2.1.5</version>
        <classifier>static-web</classifier>
    </dependency>
    

    在应用程序中实现Spring Boot命令行运行程序。类别:

     public class Application extends Neo4jConfiguration implements CommandLineRunner{
    

    在应用程序中自动关联对GraphDatabaseService的引用。类别:

    @Autowired
    GraphDatabaseService db;
    

    @在您的Application.class中重写从命令行运行的方法:

    @Override
    public void run(String... strings) throws Exception {
        // used for Neo4j browser
        try {
            WrappingNeoServerBootstrapper neoServerBootstrapper;
            GraphDatabaseAPI api = (GraphDatabaseAPI) db;
    
            ServerConfigurator config = new ServerConfigurator(api);
            config.configuration()
                .addProperty(Configurator.WEBSERVER_ADDRESS_PROPERTY_KEY, "127.0.0.1");
            config.configuration()
                .addProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, "8686");
    
            neoServerBootstrapper = new WrappingNeoServerBootstrapper(api, config);
            neoServerBootstrapper.start();
        } catch(Exception e) {
            //handle appropriately
        }
        // end of Neo4j browser config
    }
    

    当你全部完成后,你的pplication.class应该是这样的:

    package hello;
    
    import org.neo4j.graphdb.GraphDatabaseService;
    import org.neo4j.graphdb.factory.GraphDatabaseFactory;
    import org.neo4j.kernel.GraphDatabaseAPI;
    import org.neo4j.server.WrappingNeoServerBootstrapper;
    import org.neo4j.server.configuration.Configurator;
    import org.neo4j.server.configuration.ServerConfigurator;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.CommandLineRunner;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.context.annotation.Import;
    import org.springframework.data.neo4j.config.EnableNeo4jRepositories;
    import org.springframework.data.neo4j.config.Neo4jConfiguration;
    import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
    
    @Configuration
    @EnableNeo4jRepositories
    @Import(RepositoryRestMvcConfiguration.class)
    @EnableAutoConfiguration
    public class Application extends Neo4jConfiguration implements CommandLineRunner{
    
        public Application() {
            setBasePackage("hello");
        }
    
        @Bean(destroyMethod = "shutdown")
        public GraphDatabaseService graphDatabaseService() {
            return new GraphDatabaseFactory().newEmbeddedDatabase("target/hello.db");
        }
    
        @Autowired
        GraphDatabaseService db;
    
    
    
        @Override
        public void run(String... strings) throws Exception {
            // used for Neo4j browser
            try {
                WrappingNeoServerBootstrapper neoServerBootstrapper;
                GraphDatabaseAPI api = (GraphDatabaseAPI) db;
    
                ServerConfigurator config = new ServerConfigurator(api);
                config.configuration()
                        .addProperty(Configurator.WEBSERVER_ADDRESS_PROPERTY_KEY, "127.0.   0.1");
                config.configuration()
                        .addProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, "8686");
    
                neoServerBootstrapper = new WrappingNeoServerBootstrapper(api, config);
                neoServerBootstrapper.start();
            } catch(Exception e) {
                //handle appropriately
            }
            // end of Neo4j browser config
        }
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    
    
    }
    

    Neo4j浏览器将在run()方法中配置的主机和端口上可用。

  •  类似资料:
    • 问题内容: 我正在从“ 使用REST访问Neo4j数据”示例中引导一个新项目。该示例使用嵌入式数据库而不是独立的neo4j服务器,但是我想使用Neo4J Webadmin界面来可视化我的数据。如何从此配置开始启用Webadmin界面? (他们让WrappingNeoServerBootstrapper与spring-data-neo4j一起使用WrappingNeoServerBootstrapp

    • 我有一个简单的测试项目,其中使用spring boot版本:2.1.0版本检查spring-data-neo4j(https://github.com/tomkasp/neo4j-playground/blob/master/src/main/java/com/athleticspot/neo4jplayground/domain/atherepository.java) spring-data-

    • 我们将mysql与hibernate4一起用于我们的一个应用程序。我们正在数据库中存储一些错误消息。下面是用于以DB存储当前时间的类属性。 现在,我们试图将这些数据存储在Neo4J graph DB和mysql DB中。我们也不想改变这个类当前的行为。 当我试图将此对象保存在Neo4J DB中时,它会抛出异常,如下所示: 原因:java.lang.IllegalArgumentException:

    • 问题内容: 我如何才能达到与以下代码等效的效果: …但是使用Spring和Spring-Data-JPA批注? 我现有代码的基础是: 但是我不知道如何指定方法中的所有操作都应使用悲观锁集。 有一个Spring Data JPA批注,允许您设置,但是我不知道将其放在方法上是否有效。听起来更像是的注解,因为Javadoc说: org.springframework.data.jpa.repositor

    • 问题内容: 我有一个应用程序,它使用MySQL和通过REST的Neo4j服务器版本执行一些批处理作业。 我无法弄清楚如何使它们正确地协同工作:我可以使它们两个同时工作,但不能同时工作。我发现的帖子并非特定于Neo4j的服务器版本,也许就是问题所在,因为其他一切对我来说似乎都不错。 我的配置: JpaConfig Neo4j.xml 通过这种配置,Mysql可以完美工作,但是Neo4j不会将任何属性

    • 我试图使用java.lang.字符串作为NodeEntity的@Id。 根据Spring数据neo4j文档应该是可能的: 当我尝试插入时,我得到一个: 这很奇怪,因为String实现了可序列化。有人知道下一步去哪里搜索吗?