【发布时间】:2020-12-15 03:09:09
【问题描述】:
我在我的 spring(不是 spring boot)应用程序中添加了一个新的 querydsl 控制器方法。
@GetMapping("/watcher")
@ResponseBody
public List<Watcher> getWatchers(final Predicate predicate) {
return repo.findAll(predicate);
}
我还在我的 WebMvcConfigurer 实现中添加了以下注释:
@EnableSpringDataWebSupport
应用程序按预期使用这个新端点。我现在想添加一个 Spring IT 测试来测试这个新特性。
这是测试:
@Test
public void test() {
mvc.perform(get("/watcher"));
}
测试类包含以下注解:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringITConfig.class)
@WebAppConfiguration
其他测试存在于同一类中,perform() 适用于这些测试,但这是我第一次向 querydsl 控制器添加测试。
测试失败,No primary or default constructor found for interface com.querydsl.core.types.Predicate。
我尝试将注释 @EnableSpringDataWebSupport 添加到我的测试中,但它并没有改变任何东西。
我错过了什么?
谢谢
【问题讨论】:
-
你检查过这篇帖子stackoverflow.com/questions/50679551/… ??
-
是的,它说要将注释
EnableSpringDataWebSupport也添加到测试中,正如我在问题中提到的那样,但它不会改变结果
标签: java spring spring-mvc spring-data querydsl