I'm trying to implement a controller method similar to how is documented in the latest Gosling release train of Spring Data that supports QueryDsl. I've implemented the controller as shown in the example in the docs at http://docs.spring.io/spring-data/jpa/docs/1.9.0.RELEASE/reference/html/#core.web.type-safe. Everything compiles and when I start the application (using Spring Boot 1.2.5.RELEASE), everything starts fine.
However, when I try to call my rest endpoint, I always get the following exception:
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)
My guess is that the QuerydslPredicateArgumentResolver
is not being applied to the request, and thus the exception. But I see that the QuerydslPredicateArgumentResolver
is registered as a bean when I query the Spring Boot manage endpoint /manage/beans
. I have also ensured that @EnableSpringDataWebSupport
is on my @Configuration
class to no effect.
I have the controller annotated with @BasePathAwareController
, since I'm using this with Spring Data REST and I want the methods to be under a similar path as the ones that Spring Data REST exposes. I also tried using @RepositoryRestController
, but that didn't seem to matter. However, when using @RestController
and putting it under a path that was different then the base path that Spring Data REST is using, things worked. So the question is, should it work?
The entire controller right now is:
@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 Page<Avail> getAvails(Model model,
@QuerydslPredicate(root = Avail.class) Predicate predicate,
Pageable pageable,
@RequestParam MultiValueMap<String, String> parameters)
{
return repo.findAll(predicate, pageable);
}
}