我正在按照一个简单的教程来测试 Spring Data Rest 的行为,并使用 @RestResource 注释对存储库进行注释。我有一个非常简单的场景: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);
}
我使用注释配置初始化并尝试注册 RepositoryRestMvcConfiguration,因此可以注册 UserRepository。但我的应用程序没有启动,我有以下异常
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]
我使用 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