繁体   English   中英

控制器中的可分页未实例化

[英]Pageable in controller not instantiated

我有一个带有控制器的 spring-boot 应用程序,它使用 Pageable 作为其方法之一的参数。 它工作正常。 但是我想使用 spring-contract-verifier 来生成和执行测试。 测试的基类如下所示:

public class MvcTest {

    @Before
    public void setup() {
        RestAssuredMockMvc.standaloneSetup(new Controller());
    }
}

我得到的例外是:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.domain.Pageable]: Specified class is an interface
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:99)

我搜索了SO,发现我应该添加

@EnableSpringDataWebSupport

到我的配置类。 我创建了一个类:

@Configuration
@EnableWebMvc
@EnableSpringDataWebSupport
public class WebConfig {
}

但是,我不确定如何告诉合同验证程序将此类拉入配置中。 谢谢

它是错误的可分页:使用org.springframework.data.domain.Pageable而不是java.awt.print.Pageable

你需要启用

 @EnableSpringDataWebSupport

或者

 <bean class="org.springframework.data.web.config.SpringDataWebConfiguration" />

@see: http : //docs.spring.io/spring-data/jpa/docs/current/reference/html/#core.web

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM