SND - 环境配置

pom.xml


    <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.yml


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 配置

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());
    }

}

 

官方文档 - 开始:

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

配置文档:

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

配置:

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

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

集群:

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

 

 

 

 

转载于:https://my.oschina.net/u/2552286/blog/3072578

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值