Question

I was following a simple tutorial to test the behavior of spring data rest, with annotating a repository with @RestResource annotation. I have very simple scenario: Jpa User Entity and UserRepository annotated with @RestResource

@RestResource(path="users", rel="users")
public interface UserRepository extends PagingAndSortingRepository<User, Long> {

List<User> findUserByUserName(@Param("userName")String userName);
}

I use annotation config initialization and I try to register RepositoryRestMvcConfiguration, so the UserRepository can be registered. But my application is not starting and I have the following exception

INFO  Registering annotated classes: [class org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration,class com.ncau.WebMvcConfiguration]
ERROR Context initialization failed 
java.lang.ClassCastException: [Lorg.springframework.hateoas.config.EnableHypermediaSupport$HypermediaType; cannot be cast to org.springframework.hateoas.config.EnableHypermediaSupport$HypermediaType
at org.springframework.hateoas.config.HypermediaSupportBeanDefinitionRegistrar.registerBeanDefinitions(HypermediaSupportBeanDefinitionRegistrar.java:90) ~[spring-hateoas-0.8.0.RELEASE.jar:na]

I use spring-hateoas: 0.8.0.RELEASE spring-data-rest-webmv: 2.0.0.RC1 spring-framework: 4.0.0.RELEASE spring-data-jpa:1.4.3

Was it helpful?

Solution

For SDR 2.0.0.RC1, use

spring-hateoas 0.9.0.RELEASE
spring-data-jpa 1.5.0.RC1

SDR will export all repositories by default, you don't need to annotate them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top