我正试图通过SDR访问mongodb集合.目前使用以下版本
我的存储库看起来像
@RepositoryRestResource
@PreAuthorize("hasAuthority('ROLE_USER')")
public interface LinksRepository extends MongoRepositoryaram("regex") String regex,Pageable p);
我的模型定义如下
@Document(collection = "links")
public class Link {
public Link() {}
@Id
private String id;
当我点击http://localhost:9090/api/links时,我得到以下异常
java.lang.IllegalArgumentException: PersistentEntity must not be null!
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.data.rest.webmvc.PersistentEntityResource$Builder.java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.web.method.support.invocableHandlerMethod.doInvoke(invocableHandlerMethod.java:222)
at org.springframework.web.method.support.invocableHandlerMethod.invokeForRequest(invocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletinvocableHandlerMethod.invokeAndHandle(ServletinvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:775)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.dispatcherServlet.dodispatch(dispatcherServlet.java:959)
at org.springframework.web.servlet.dispatcherServlet.doService(dispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:965)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:856)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
挖了一点我发现MongoMappingContext没有类链接,因为它应该(我猜)
我花了几个小时试图搞清楚但没有运气.我没有使用弹簧启动,它感觉它可能是一个ObjectMapper问题,但我不知道,我的域和设置很简单….任何帮助非常感谢.
提前致谢.
最佳答案
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。