简体   繁体   English

neo4j保存到数据库并在neo4j浏览器Java中显示

[英]neo4j save to database and display in neo4j browser java

I have a java project in eclipse that stores a graph into a Neo4j database like this: 我在eclipse中有一个Java项目,该项目将图形存储到Neo4j数据库中,如下所示:

Node e = graphDb.createNode(label);
e.setProperty(V_TYPE, PORTFOLIO_V_TYPE);
e.setProperty("Name", "Hey");       
e.setProperty("Code", "My code");
e.setProperty("Idea", "My idea");
porfolios.add(e);

(obviously adding way more than just this one and also adding relationships) (显然,添加的方式不仅限于此,还添加了关系)

MY QUESTION IS! 我的问题是! : how can I visualize the resulting graph (in this case just that one node...)? :如何可视化结果图(在这种情况下,只有一个节点...)? in other words, is there any way to connect to the neo4j browser so that I don't have to make my own UI? 换句话说,有什么方法可以连接到neo4j浏览器,从而不必创建自己的UI?
These are my imports: 这些是我的进口:

import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Path;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.ResourceIterator;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.schema.IndexDefinition;
import org.neo4j.graphdb.schema.Schema;
import org.neo4j.graphdb.traversal.Evaluators;
import org.neo4j.graphdb.traversal.TraversalDescription;
import org.neo4j.graphdb.traversal.Traverser;

The maven dependency I am using is the: 我正在使用的Maven依赖项是:

<dependency>
  <groupId>org.neo4j</groupId>
  <artifactId>neo4j</artifactId>
  <version>3.4.0</version>
</dependency>

When you create the database in joava, you also need to enable the BOLT protocol. 在joava中创建数据库时,还需要启用BOLT协议。 You can take a look at the documentation : https://neo4j.com/docs/java-reference/current/tutorials-java-embedded/#tutorials-java-embedded-bolt 您可以看一下文档: https : //neo4j.com/docs/java-reference/current/tutorials-java-embedded/#tutorials-java-embedded-bolt

Firstly import the bolt jar in your project 首先在您的项目中导入螺栓罐

  <dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-bolt</artifactId>
    <version>3.4.0</version>
  </dependency>

And then configure the database to enable the bolt protocol : 然后配置数据库以启用Bolt协议:

GraphDatabaseSettings.BoltConnector bolt = GraphDatabaseSettings.boltConnector( "0" );

GraphDatabaseService graphDb = new GraphDatabaseFactory()
        .newEmbeddedDatabaseBuilder( DB_PATH )
        .setConfig( bolt.type, "BOLT" )
        .setConfig( bolt.enabled, "true" )
        .setConfig( bolt.address, "localhost:7687" )
        .newGraphDatabase();

At this moment you can take the neo4j desktop version, and create a remote connection, and use the browser. 此时,您可以使用neo4j桌面版本,创建远程连接,然后使用浏览器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM