Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure neo4j

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to install and configure neo4j. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Note: I found a lot of tutorials on the Internet and found that they were not suitable for basic 0 users, so I wrote it myself.

Version 1.x is recommended, and a large number of functions have been abandoned after testing.

Installation startup

Download the tar package on the official website

Decompress, enter bin, and run. / neo4j

Open localhost:7474 in url and use it.

Configuration

Location settings for the database.

Modify line 14 org.neo4j.serve.database.location= in conf/neo4j-server.properties

Use

The tool for 1.web to visualize neo4j is webadmin. Open it by opening local/webadmin in url and you can use it.

Note: when the code modifies the database, it seems that each restart of neo4j is required to display in webadmin, or it may be due to slow data synchronization.

two。 Simple instance (java operation neo4j)

Package neo4j;import java.io.File;import java.io.IOException;import javax.management.relation.Relation;import org.neo4j.graphdb.GraphDatabaseService;import org.neo4j.graphdb.Node;import org.neo4j.graphdb.Relationship;import org.neo4j.graphdb.RelationshipType;import org.neo4j.graphdb.Transaction;import org.neo4j.graphdb.factory.GraphDatabaseFactory;import org.neo4j.io.fs.FileUtils Public class test {public enum RelTypes implements RelationshipType {KNOWS} private static void registerShutdownHook (final GraphDatabaseService graphDb) {/ / Registers a shutdown hook for the Neo4j instance so that it / / shuts down nicely when the VM exits (even if you "Ctrl-C" the / / running example before it's completed) / * to ensure that the neo4j database is properly shut down, we can add a shutdown hook method * registerShutdownHook. This method means to add a closed * hook to the jvm. When jvm is closed, all hooks that have been set in the system to be added through the method * addShutdownHook will be executed, and jvm will not be closed until the system has finished executing these hooks. * so these hooks can perform memory cleanup, object destruction and other operations when jvm is closed. * / Runtime.getRuntime () .addShutdownHook (new Thread () {@ Override public void run () {graphDb.shutdown ();}});} public static void main (String [] args) throws IOException {FileUtils.deleteRecursively (new File ("db")); GraphDatabaseService graphdb=new GraphDatabaseFactory () .newEmbeddedDatabase ("db"); Relationship relationship; Transaction tx=graphdb.beginTx (); try {Node node1=graphdb.createNode (); Node node2=graphdb.createNode () Node1.setProperty ("message", "Hello"); node2.setProperty ("message", "World"); relationship = node1.createRelationshipTo (node2, RelTypes.KNOWS); relationship.setProperty ("message", "brave neo4j"); tx.success (); System.out.println ("successfully");} finally {tx.finish ();} registerShutdownHook (graphdb);}} Thank you for reading! This is the end of this article on "how to install and configure neo4j". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report