zoukankan      html  css  js  c++  java
  • 基于SDN4.2.4的neo4j实例

    首先添加maven依赖 

    (1)SND的声明

    <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j</artifactId>
    <version>4.2.4.RELEASE</version>
    </dependency>

    (2)neo4j-ogm-test的声明

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>4.3.9.RELEASE</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    </dependency>

    <dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-test</artifactId>
    <version>2.1.1</version>
    <type>test-jar</type>
    <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-kernel</artifactId>
    <version>3.1.1</version>
    <type>test-jar</type>
    </dependency>

    <dependency>
    <groupId>org.neo4j.app</groupId>
    <artifactId>neo4j-server</artifactId>
    <version>3.1.1</version>
    <type>test-jar</type>
    </dependency>


    <dependency>
    <groupId>org.neo4j.test</groupId>
    <artifactId>neo4j-harness</artifactId>
    <version>3.1.1</version>
    <scope>test</scope>
    </dependency>

    domain model(com.neo4j.domain)

      

    @NodeEntity
    public class Movie {
    @GraphId
    private Long id;

    private String title;

    public String getTitle() {
    return title;
    }

    public void setTitle(String title) {
    this.title = title;
    }

    public Movie(){

    }
    public Movie(String title){
    this.title = title;
    }

    }

    repository(com.neo4j.repositories)

    public interface PersonRepository extends Neo4jRepository<Person,Long>{
    Person findByName(String name);
    }

    configuration(ogm.repositories,SDN会自动扫描该文件,以及配置方法的声明和一个使用实例)

    driver=org.neo4j.ogm.drivers.http.driver.HttpDriver
    URI=http://neo4j:peijie@localhost:7474

    @Configuration
    @EnableNeo4jRepositories(basePackages = "com.neo4j.repository")
    @EnableTransactionManagement
    @ComponentScan("com.neo4j")
    public class MyConfiguration {
    @Bean
    public SessionFactory sessionFactory() {
    // with domain entity base package(s)
    return new SessionFactory("com.neo4j.entity");
    }

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

    }

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(classes = {MyConfiguration.class})
    public class PersonTest {
    @Autowired
    PersonRepository personRepository;

    @Test
    public void test(){
    Person person = new Person("哈士奇","安徽","拆家");
    personRepository.save(person);
    System.out.println("保存成功!");
    }
    }


  • 相关阅读:
    关于post和get的区别
    修改ubuntu系统时区
    修改 Ubuntu 下 Mysql 编码
    C++程序设计实践指导1.10二维数组元素换位改写要求实现
    C++程序设计实践指导1.7超长数列中n个数排序改写要求实现
    C++程序设计实践指导1.15找出回文数改写要求实现
    C++程序设计实践指导1.14字符串交叉插入改写要求实现
    C++程序设计实践指导1.13自然数集中找合数改写要求实现
    C++程序设计实践指导1.12数组中数据线性变换改写要求实现
    C++程序设计实践指导1.9统计与替换字符串中的关键字改写要求实现
  • 原文地址:https://www.cnblogs.com/shirandedan/p/7198074.html
Copyright © 2011-2022 走看看