Spring Data Neo4j "No property get found for type"例外



我试图将现有项目转换为使用Spring Data和Neo4j,但遇到了一些问题。当我尝试构建项目时,我得到以下异常:

[etc. ...]
Caused by: 
org.springframework.data.mapping.PropertyReferenceException: No property get found for type com.myproject.models.SuperNode
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
[... etc.]

我似乎找不到任何好的信息,为什么我会得到那个错误,我不确定到底是什么原因造成的。

以下是大多数SuperNode类:

@NodeEntity
public class SuperNode extends AbstractMapValues {
    @GraphId
    private Long superNodeId;
    @NotNull
    private boolean superNodeFullyGenerated = false;
    private BaseLandType likelyLandType;
    private BaseLandType unlikelyLandType;
[methods and such]
}

它源自AbstractMapValues类:

@NodeEntity
public abstract class AbstractMapValues implements Comparable<AbstractMapValues> {
    @GraphId
    public Long id;
    @Range(min = 0, max = MAX_MAP_INT)
    private int xCoor;
    @Range(min = 0, max = MAX_MAP_INT)
    private int yCoor;
    //set only when x and y are set
    @Indexed(indexType = IndexType.POINT)
    private String wkt;
    @Range(min = BASIC_MIN, max = BASIC_MAX)
    private int percipitation;
    @Range(min = -1, max = BASIC_MAX)
    private int topography;
    @Range(min = BASIC_MIN, max = BASIC_MAX)
    private int seaLevel;
 [more int fields, but you get the picture]
 }

正如你所看到的,这些是用来表示地图中的点的。我的项目中有一个Neo4j空间依赖项,它应该允许我使用IndexType.POINT.

然后我有了SuperNode的存储库。我有我的基本CRUD类型存储库接口,一个由基本存储库实现的自定义接口,这样我就可以实现自定义接口,并写出需要使用Neo4j空间库的get方法。

基本回购:

public interface SuperNodeRepo extends CRUDRepository<SuperNode>, SpatialRepository<SuperNode>, SuperNodeRepoCustom {
}

自定义界面:

@NoRepositoryBean
public interface SuperNodeRepoCustom {
    public SuperNode getSuperNode(int xCoorSuperNode, int yCoorSuperNode) ;
    public List<SuperNode> getSuperNodes(int xmax, int xmin, int ymax, int ymin) ;
}

自定义实现(正如您所看到的,它目前还不完整(:

公共类SuperNodeRepoCustomImpl实现SuperNodeRepoCustom{

public SuperNode getSuperNode(int xCoorSuperNode, int yCoorSuperNode) {
    return null;
}
public List<SuperNode> getSuperNodes(int xmax, int xmin, int ymax, int ymin) {
    return null;
}

}

我尝试过将@Indexed直接添加到SuperNode中的新字段中,但这没有帮助。我在没有扩展spatialRepo的情况下尝试过。

当我在没有扩展自定义界面的情况下尝试它时,我会得到一个不同的错误:

No matching bean of type [com.orclands.game.models.SuperNode] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

但我仍然不知道为什么会这样。最后,我有两个问题。A.我的自定义接口实现有什么问题,B.除此之外还有什么问题!

如有任何帮助,我们将不胜感激!

**@Repository**
public interface SuperNodeRepo extends CRUDRepository<SuperNode>, SpatialRepository<SuperNode>, SuperNodeRepoCustom {
}

相关内容

最新更新