SND - 環境配置

pom.xmlhtml

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-neo4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
       
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

application.ymljava

spring:
  data:
    neo4j:
      username: neo4j
      password: 123456
      uri: bolt://localhost:7687
      auto-index: update
      open-in-view: true
      repositories:
        enabled: true
      embedded:
        enabled: true

 

或 java 配置web

package org.canaan.neo4j.config;

import org.neo4j.ogm.session.SessionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.annotation.EnableNeo4jAuditing;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.transaction.Neo4jTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author Canaan
 * @date 2019/7/11 9:16
 */
@Configuration
@EnableNeo4jRepositories(basePackages = "org.canaan.neo4j.graph")
@EnableTransactionManagement // 激活SDN隱式事務
@EnableNeo4jAuditing
public class Neo4jConfigurer {

    @Value("${neo4j.uri}")
    private String uri;

    @Value("${neo4j.username}")
    private String username;

    @Value("${neo4j.password}")
    private String password;

    @Value("${neo4j.connection.pool.size}")
    private Integer connectionPoolSize;


    @Bean
    public SessionFactory sessionFactory() {
        return new SessionFactory(configuration(), "org.canaan.neo4j.graph");
    }

    @Bean
    public org.neo4j.ogm.config.Configuration configuration() {
        return new org.neo4j.ogm.config.Configuration.Builder()
                .uri(uri)
                .credentials(username, password)
                .connectionPoolSize(connectionPoolSize)
                .autoIndex("update")
                .build();
    }

    @Bean
    public Neo4jTransactionManager transactionManager() {
        return new Neo4jTransactionManager(sessionFactory());
    }

}

 

官方文檔 - 開始:spring

https://docs.spring.io/spring-data/neo4j/docs/5.1.3.RELEASE/reference/html/#referencebash

配置文檔:session

https://docs.spring.io/spring-data/neo4j/docs/5.1.3.RELEASE/reference/html/#reference.getting_started.spring-configurationapp

配置:maven

https://docs.spring.io/spring-data/neo4j/docs/5.1.3.RELEASE/reference/html/#reference:configurationspring-boot

索引策略文檔:
https://docs.spring.io/spring-data/neo4j/docs/5.1.3.RELEASE/reference/html/#reference:indexing:creationui

集羣:

https://docs.spring.io/spring-data/neo4j/docs/5.1.3.RELEASE/reference/html/#reference_clustering


高可用:

https://docs.spring.io/spring-data/neo4j/docs/5.1.3.RELEASE/reference/html/#reference:ha

相關文章
相關標籤/搜索