【问题标题】:get value from imported class for interface从接口的导入类中获取值
【发布时间】:2017-10-03 18:55:50
【问题描述】:

设置

我通过

从我的 Java 项目中导入一个类
import myproj.domain.ActionResponse;

然后我尝试通过扩展 Neo4jRepository 为存储库创建一个接口。

我正在关注这些文档: "参数类型从<T> 更改为<T, ID>" - https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/

@Repository
    public interface ActionResponseRepository extends Neo4jRepository<ActionResponse, ActionResponse.getId() >  {
...

ActionResponse 扩展了 NamedType,它扩展了具有

的 GraphType
...
@GraphId
    @JsonProperty("id")
    Long id;

    public Long getId() {
        return id;
    }
...

问题

这个: extends Neo4jRepository&lt;ActionResponse, ActionResponse.getId() &gt; 语法不正确。

如何使用 ActionReponse 类中的 id 填充第二个参数字段?

【问题讨论】:

    标签: java neo4j spring-data-neo4j spring-data-neo4j-5


    【解决方案1】:

    注解的第二个参数是IDtype

    所以你应该声明如下:

    extends Neo4jRepository<ActionResponse, Long>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-08
      • 2021-07-26
      • 1970-01-01
      • 2012-07-31
      • 2011-03-18
      • 2015-05-27
      • 2015-04-23
      • 2013-01-15
      相关资源
      最近更新 更多