Reputation: 297
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
Upvotes: 4
Views: 1235
Reputation: 48236
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.
Upvotes: 3