zoukankan      html  css  js  c++  java
  • 心态炸了,我再写一个4.1.0版本的SND实例

    maven依赖

    <!-- Tests -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>4.2.5.RELEASE</version>
    <scope>test</scope>
    </dependency>

    <!--SDN-->
    <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j</artifactId>
    <version>4.1.0.RELEASE</version>
    </dependency>

    <!--Neo4j-->
    <dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-test</artifactId>
    <version>2.1.0</version>
    <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-kernel</artifactId>
    <version>3.1.0</version>
    </dependency>

    <dependency>
    <groupId>org.neo4j.app</groupId>
    <artifactId>neo4j-server</artifactId>
    <version>3.1.0</version>
    </dependency>

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

    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
    </dependency>

    domain model(com.shubo.neo4j.domain)

    @NodeEntity
    public class Person {
    @GraphId
    private Long nodeId;
    String name;
    String from;
    String hobbies;

    public Person(){
    }

    public Person(String name,String from, String hobbies){
    this.name = name;
    this.from = from;
    this.hobbies = hobbies;
    }

    }

    repository(com.shubo.neo4j.repositories)

    public interface PersonRepository extends GraphRepository<Person> {
    }

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

    @Configuration
    @EnableNeo4jRepositories(basePackages = "com.shubo.neo4j.repository")
    @EnableTransactionManagement
    @ComponentScan("com.shubo.neo4j")
    public class MyConfiguration extends Neo4jConfiguration{
    @Bean
    public SessionFactory getSessionFactory(){
    return new SessionFactory("com.shubo.neo4j.domain");
    }

    @Bean
    public Session getSession() throws Exception {
    return super.getSession();
    }
    }

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(classes = {MyConfiguration.class})
    public class Neo4jTest {

    @Autowired
    PersonRepository personRepository;

    @Test
    public void testCRUDPerson(){
    System.out.println(personRepository.getClass());
    Person person = new Person("Jerry","China","LOL");
    personRepository.save(person);
    System.out.println("保存成功");
    }
    }


  • 相关阅读:
    Vim命令合集
    感知机算法
    【项目】搜索广告CTR预估(二)
    【项目】搜索广告CTR预估(一)
    Kernel Logestic Regression
    SVM3 Soft Margin SVM
    Bias and Variance
    SVM2---核函数的引入
    贪心题目汇总
    Divergent series
  • 原文地址:https://www.cnblogs.com/shirandedan/p/7199459.html
Copyright © 2011-2022 走看看