我正在尝试实现一种控制器方法,类似于支持QueryDsl的最新Gosling发布的Spring Data发布系列中记录的方法.我已经实现了控制器,如http://docs.spring.io/spring-data/jpa/docs/1.9.0.RELEASE/reference/html/#core.web.type-文档中的示例所示.安全.一切都在编译,当我启动应用程序时(使用Spring Boot 1.2.5.RELEASE),一切都很顺利.
但是,当我尝试调用我的rest端点时,我总是得到以下异常:
org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mysema.query.types.Predicate]: Specified class is an interface
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:101)
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.createAttribute(ModelAttributeMethodProcessor.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.createAttribute(ServletModelAttributeMethodProcessor.java:80)
Run Code Online (Sandbox Code Playgroud)
我的猜测是,QuerydslPredicateArgumentResolver没有应用于请求,因此异常.但是QuerydslPredicateArgumentResolver当我查询Spring Boot管理端点时,我看到它被注册为bean /manage/beans.我也确保@EnableSpringDataWebSupport我的@Configuration班级没有效果.
我对控制器进行了注释@BasePathAwareController,因为我在Spring Data REST中使用它,我希望这些方法与Spring Data REST公开的方法类似.我也尝试过使用@RepositoryRestController,但这似乎并不重要.但是,当使用@RestController并将其放在与Spring Data REST正在使用的基本路径不同的路径下时,一切正常.所以问题是,它应该有效吗?
现在整个控制器是:
@RestController
@RequestMapping(value = "/query")
public class AvailController
{
private final AvailRepository repo;
@Autowired
public AvailController(AvailRepository repository)
{
this.repo = repository;
}
@RequestMapping(value = "/avails", method = GET)
public @ResponseBody …Run Code Online (Sandbox Code Playgroud) 我有一个Spring Data Rest Repository控制器,它使用JPA进行查询实现,我需要添加一些使用JPA支持的标准queryByExample方法无法完成的自定义查询方法.我创建了一个具有必要方法的Impl类,但我不能让它被识别.我看到我可以使用标准的Spring MVC Controller,但我希望有一个统一的API,基本上我真正想要的是实现我自己的自定义/搜索方法.
即使使用自定义控制器,问题仍然是不再提供HAL链接和其他相关项目.
春天的人们可以花一些时间让某人记录如何做一些这些更高级的东西吗?我猜测,有时必须实现自己的搜索方法是相当普遍的,并且花费时间来明确如何做到这一点.
我有一个现有的Spring Cloud Feign客户端界面,它为我的服务器端API提供了许多映射.我正在添加一些新方法,我突然遇到错误.我正在尝试添加表单的方法:
@RequestMapping(value = "/tasks/{id}", method = GET)
public Resource<Task> getTask(@PathVariable("id")Long id);
Run Code Online (Sandbox Code Playgroud)
一切都编译得很好,但是当我尝试调用上面的getTask()方法时,我总是得到一个IllegalArgumentException抱怨URL无效.这是真的,因为URL仍然包含UriTemplate {id}.
完整的堆栈是:
java.lang.IllegalArgumentException: Illegal character in path at index 29: http://connect/connect/tasks/{id}
at java.net.URI$Parser.fail(URI.java:2848)
at java.net.URI$Parser.checkChars(URI.java:3021)
at java.net.URI$Parser.parseHierarchical(URI.java:3105)
at java.net.URI$Parser.parse(URI.java:3053)
at java.net.URI.<init>(URI.java:588)
at java.net.URI.create(URI.java:850)
at feign.ribbon.RibbonClient.execute(RibbonClient.java:64)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:92)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:71)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:94)
at com.sun.proxy.$Proxy55.getTask(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
在同一个界面中有许多其他方法使用这种完全相同的模式,一切运行正常.我不能为我的生活找出为什么Feign/Spring突然出现这种方法的问题.我已经尝试了所有可能的设置组合和编写方法的方法.如果我只是删除了{id},那么调用将会通过,但显然会返回错误的数据,因为它缺少URI的id部分.
我正在使用Spring Cloud Angel.SR6和Spring Boot 1.2.8以及Feign 8.5.0.
我正在努力启用 Spring Cloud Config 并使一切正常。但是,我在我的服务应用程序日志中看到 INFO 消息,表明 Cloud Config 客户端希望大约每 30 秒从服务器重新加载一次配置。我在文档中甚至在代码中都找不到任何内容来说明为什么会发生这种情况。我真的不希望我的服务几乎如此频繁地轮询配置服务器,理想情况下我想将其关闭,这样我就可以更好地控制何时发生配置刷新。
谁有想法?