小编Ken*_*ani的帖子

如何在Spring Boot应用程序中的同一域类上使用Spring Data JPA和Spring Data Elasticsearch存储库?

我试图在同一个域对象上使用Spring Data JPA和Spring Data Elasticsearch,但它不起作用.

当我尝试运行一个简单的测试时,我得到以下异常:

org.springframework.data.mapping.PropertyReferenceException:找不到Person类型的属性索引!org.springframework.data.mapping.PropertyPath.(PropertyPath.java:75)〜[spring-data-commons-1.11.0.RELEASE.jar:na] at org.springframework.data.mapping.PropertyPath.create(PropertyPath .java:327)〜[spring-data-commons-1.11.0.RELEASE.jar:na] org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307)〜[spring-data-commons- 1.11.0.RELEASE.jar:na] at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270)〜[spring-data-commons-1.11.0.RELEASE.jar:na] at org. springframework.data.mapping.PropertyPath.from(PropertyPath.java:241)〜[spring-data-commons-1.11.0.RELEASE.jar:na] at org.springframework.data.repository.query.parser.Part.( Part.java:76)〜[spring-data-commons-1.11.0.RELEASE.jar:

它们在禁用任何一个时都有效.

该项目基于Spring Boot 1.3.0.M5.

这是一个重现情况的示例项目:

https://github.com/izeye/spring-boot-throwaway-branches/tree/data-jpa-and-elasticsearch

spring-data spring-data-jpa spring-boot spring-data-elasticsearch

10
推荐指数
2
解决办法
8124
查看次数

如何使用Spring Boot将H2连接到远程数据库而不是嵌入模式?

对于我的小型Spring Boot应用程序,我在src/main/resources下有这个配置:

server.port = 8090
spring.datasource.driverClassName = org.h2.Driver
spring.datasource.url = jdbc:h2:file:~/stapler
Run Code Online (Sandbox Code Playgroud)

我知道此配置已正确选取,因为应用程序启动日志中有有效的端口号8090.还有一个@PostConstruct initDb()方法,它创建数据并将数据插入该数据库的2个表中:

package com.avk.stapler.init;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class DbInitializer {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public static void main(String[] args) {
        SpringApplication.run(DbInitializer.class, args);
    }

    @PostConstruct
    private void initDb() {
        System.out.println("Creating table employees");
        jdbcTemplate.execute("drop table employees if exists");
        jdbcTemplate.execute("create table employees(id serial, name varchar(255), surname varchar(255))");
        jdbcTemplate.execute("insert into employees(name, surname) values('Jan', 'Kowalski')");
        jdbcTemplate.execute("insert into employees(name, surname) values('Stefan', 'Nowak')");


        System.out.println("Creating table allocations");
        jdbcTemplate.execute("drop …
Run Code Online (Sandbox Code Playgroud)

java h2 spring-data spring-boot

3
推荐指数
1
解决办法
9554
查看次数

如何创建自引用节点?

...或者是否可以在Neo4j中创建一个与自身有关系的节点(一个简单的循环节点)?

如果是这样,相应的Cypher查询是什么?

neo4j graph-databases cypher

2
推荐指数
1
解决办法
1403
查看次数