【问题标题】:Spring Data Rest and HateoasSpring Data Rest 和 Hateoas
【发布时间】:2014-03-07 03:25:01
【问题描述】:

我正在按照一个简单的教程来测试 Spring Data Rest 的行为,并使用 @RestResource 注释对存储库进行注释。 我有非常简单的场景: 用@RestResource注解的Jpa用户实体和UserRepository

@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]

我用 春天仇恨:0.8.0.RELEASE 弹簧数据休息webmv:2.0.0.RC1 弹簧框架:4.0.0.RELEASE spring-data-jpa:1.4.3

【问题讨论】:

    标签: spring spring-data-jpa spring-data-rest spring-hateoas


    【解决方案1】:

    对于 SDR 2.0.0.RC1,使用

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

    默认情况下,SDR 将导出所有存储库,您无需对其进行注释。

    【讨论】:

      猜你喜欢
      • 2013-10-31
      • 2014-08-16
      • 2016-05-23
      • 2014-07-05
      • 2018-07-23
      • 2018-11-26
      • 2011-11-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多