Spring-data-Neo4j: OGM Reference Documentation

  1. Neo4j OGM是Neo4j的快速对象图形映射库,针对使用Cypher的基于服务器的安装进行了优化.
  2. OGM专注于性能,引入了许多创新,其中包括:

    基于非反射的类路径扫描的启动时间更快;
    
    可变深度持久性,允许您根据图形的特征​​对请求进行微调;
    
    智能对象映射以减少对数据库的冗余请求,提高延迟并最大限度地减少浪费的CPU周期; 和
    
    用户可定义的会话生命周期,帮助您在应用程序的内存使用率和服务器请求效率之间取得平衡。
    
    1. 依赖 maven
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-core</artifactId>
    <version>{ogm-version}</version>
    <scope>compile</scope>
</dependency>

<!-- Only add if you're using the HTTP driver -->
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-http-driver</artifactId>
    <version>{ogm-version}</version>
    <scope>runtime</scope>
</dependency>

<!-- Only add if you're using the Embedded driver -->
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-embedded-driver</artifactId>
    <version>{ogm-version}</version>
    <scope>runtime</scope>
</dependency>

<!-- Only add if you're using the Bolt driver -->
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-bolt-driver</artifactId>
    <version>{ogm-version}</version>
    <scope>runtime</scope>
</dependency>

Gradle

dependencies {
    compile 'org.neo4j:neo4j-ogm-core:{ogm-version}'
    runtime 'org.neo4j:neo4j-ogm-http-driver:{ogm-version}' // Only add if you're using the HTTP driver
    runtime 'org.neo4j:neo4j-ogm-embedded-driver:{ogm-version}' //  Only add if you're using the Embedded driver
    runtime 'org.neo4j:neo4j-ogm-bolt-driver:{ogm-version}' // Only add if you're using the Bolt driver
}
  1. Configuration
    4.1 Configuration method
 using a properties file

programmatically using Java

by providing an already configured Neo4j Java driver instance

4.2

ConfigurationSource props = new ClasspathConfigurationSource("my.properties");
Configuration configuration = new Configuration.Builder(props).build();

4.3 By providing a Neo4j driver instance

org.neo4j.driver.v1.Driver nativeDriver = ...;
Driver ogmDriver = new BoltDriver(nativeDriver);
new SessionFactory(ogmDriver, ...);

4.4.1 Driver Configuration——HTTP Driver

Configuration configuration = new Configuration.Builder()
        .uri("bolt://neo4j:password@localhost")
        .setConnectionPoolSize(150)
        .build()

4.4.3 Embedded Driver

Configuration configuration = new Configuration.Builder()
             .uri("file:///var/tmp/neo4j.db")
             .build()

4.4.4 Credentials

1、

Configuration configuration = new Configuration.Builder()
             .uri("bolt://user:password@localhost")
             .build()

2、

Configuration configuration = new Configuration.Builder()
             .credentials("user", "password")
             .build()

猜你喜欢

转载自blog.csdn.net/qq_32662595/article/details/79880950