Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pageable in controller not instantiated

Tags:

spring

testing

I have a spring-boot app with controller that uses Pageable as an argument to one of its methods. It works fine. But I want to use spring-contract-verifier to generate and execute tests. Base class for tests looks like this:

public class MvcTest {

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

The exception I'm getting is:

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)

I searched SO and I found out that I should add

@EnableSpringDataWebSupport

to my configuration class. I created a class:

@Configuration
@EnableWebMvc
@EnableSpringDataWebSupport
public class WebConfig {
}

However, I'm not sure how to tell contract verifier to pull this class into configuration. Thanks

like image 682
user2669285 Avatar asked Mar 01 '26 00:03

user2669285


1 Answers

Its the wrong pagable: use org.springframework.data.domain.Pageable instead of java.awt.print.Pageable.

you need to enable

 @EnableSpringDataWebSupport

or

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

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

like image 198
Ralph Avatar answered Mar 04 '26 16:03

Ralph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!