共計 1965 個字符,預(yù)計需要花費 5 分鐘才能閱讀完成。
自動寫代碼機器人,免費開通
這篇文章給大家分享的是有關(guān) neo4j 如何安裝配置的內(nèi)容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。
注:網(wǎng)上找了許多教程,發(fā)現(xiàn)都不太適合 0 基礎(chǔ)的用戶,所以就自己寫了一下。
推薦使用 1.x 版本,經(jīng)測試 2.3.3 大量函數(shù)被遺棄。
安裝啟動
官網(wǎng)下載 tar 包
解壓,進入 bin 下,運行./neo4j
在 url 中打開 localhost:7474 即可使用
配置
數(shù)據(jù)庫的 location 設(shè)置。
conf/neo4j-server.properties 中第 14 行 org.neo4j.serve.database.location= 進行修改
使用
1.web 可視化 neo4j 的工具是 webadmin,打開方式:url 中打開 local/webadmin,即可使用
注:代碼修改數(shù)據(jù)庫,似乎需要每次重啟 neo4j 才能在 webadmin 中顯示,也有可能是數(shù)據(jù)同步慢
2. 簡單實例(java 操作 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 {
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)
/* 為了確保 neo4j 數(shù)據(jù)庫的正確關(guān)閉,我們可以添加一個關(guān)閉鉤子方法
* registerShutdownHook。這個方法的意思就是在 jvm 中增加一個關(guān)閉的
* 鉤子,當(dāng) jvm 關(guān)閉的時候,會執(zhí)行系統(tǒng)中已經(jīng)設(shè)置的所有通過方法
* addShutdownHook 添加的鉤子,當(dāng)系統(tǒng)執(zhí)行完這些鉤子后,jvm 才會關(guān)閉。 * 所以這些鉤子可以在 jvm 關(guān)閉的時候進行內(nèi)存清理、對象銷毀等操作。*/
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
}
感謝各位的閱讀!關(guān)于“neo4j 如何安裝配置”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
向 AI 問一下細節(jié)