我在用着spring-data-neo4j
我正在尝试组合存储库以便能够使用自定义存储库。我认为我已经正确遵循了中指定的命名约定20.8.7 创建存储库 http://docs.spring.io/spring-data/neo4j/docs/3.0.2.RELEASE/reference/html/programming-model.html和其他问题,例如this https://stackoverflow.com/questions/17772700/spring-with-neo4j-graphrepository-vs-handmade-interface.
不管怎样,我做错了什么,因为我得到了这个
异常信息
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";
}
}
services
@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
错误。
需要改变UserRespositoryImpl
per UserRepositoryImpl
(没有 's': 注意 UserRespositoryImpl)。
不管怎样,我一直在努力解决自定义存储库组合问题spring-data-neo4j
我认为这可能有点令人困惑。另外我认为网上很少有好的例子......所以,最后我决定创建一个示例项目GitHub
,并通过一个基本示例展示了我们如何做到这一点。
希望它将来能帮助其他人。
请参阅 GitHub:neo4j 自定义存储库 https://github.com/troig/neo4jCustomRepository
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)