簡體   English   中英

“沒有找到類型的屬性”組合存儲庫spring-data-neo4j

[英]“No property found for type” combining repositories spring-data-neo4j

我正在使用spring-data-neo4j ,我正在嘗試組合存儲庫以便能夠使用自定義存儲庫。 我想我已經正確地按照規定的命名慣例20.8.7創建存儲庫以及其它類似的做題

無論如何,我做錯了,因為我得到了這個

異常消息

Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property someCriteria found for type User!

用戶實體

@NodeEntity
public class User {

   @GraphId
   private Long nodeId;
   @Indexed
   String mail;
   ...
}

存儲庫 (全部在同一個包中)

@Repository
public interface UserRepository extends GraphRepository<User>, UserRepositoryCustom {
   User findByMail(String mail);
}

public interface UserRepositoryCustom {
  String findBySomeCriteria(String criteria);
}

public class UserRespositoryImpl implements UserRepositoryCustom {
   @Override
   public String findBySomeCriteria(String criteria) {
      return "result";
   }
}

服務

@Service
public class UserServiceImpl implements UserService {
   @Autowired
   UserRepository userRepository;
}

Neo4j配置

<bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
      ...
</bean>
<neo4j:repositories base-package="com.mypackage.api.user.repository"/>
<bean id="userService" class="com.mypackage.api.user.service.UserServiceImpl"/>

在這種情況下,它只是一個愚蠢的spelling錯誤。

需要根據UserRepositoryImpl更改UserRespositoryImpl (不帶' s ':注意UserRe s positoryImpl)。

無論如何,我一直在使用spring-data-neo4j自定義存儲庫組合,我認為它可能有點令人困惑。 另外我認為在網上很少有很好的例子......所以,最后我決定在GitHub創建一個示例項目,其中一個基本示例展示了我們如何做到這一點。

希望它能在未來幫助其他人。

請參閱GitHub: neo4jCustomRepository

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM