我正在尝试将现有的项目转换为使用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-spatial库的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.除此之外,还有什么问题!
任何帮助都将不胜感激!
发布于 2014-01-19 05:01:42
**@Repository**
public interface SuperNodeRepo extends CRUDRepository<SuperNode>, SpatialRepository<SuperNode>, SuperNodeRepoCustom {
}https://stackoverflow.com/questions/15050267
复制相似问题