java – Spring:Spring HATEOAS 0.19.0的Spring Boot版本是什么?

weixin_38052002 2019-09-12 01:54:20
我想使用Spring HATEOAS的最新稳定版0.19.0.RELEASE.我将它与最新的稳定版本1.2.6.RELEASE的Spring Boot结合起来.在build.gradle中,我们发现了其中的一些 apply plugin: 'spring-boot' ... dependencies { compile("org.springframework.boot:spring-boot-starter-web:1.2.6.RELEASE") compile 'org.springframework.hateoas:spring-hateoas:0.19.0.RELEASE' } 当我启动主应用程序时,我得到了异常 Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.hateoas. HypermediaAutoConfiguration$HypermediaConfiguration$HalObjectMapperConfiguration': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.hateoas.hal.Jackson2HalModule$HalHandlerInstantiator.<init> (Lorg/springframework/hateoas/RelProvider;Lorg/springframework/hateoas/hal/CurieProvider;)V at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136) ... at ... Application.main(Application.java:...) 这看起来很糟糕,但我们可以翻译它.一方面,在spring-boot-autoconfigure-1.2.6.RELEASE.jar的org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration中,我们发现 public class HypermediaAutoConfiguration { ... protected static class HypermediaConfiguration { ... protected static class HalObjectMapperConfiguration { ... private void registerHalModule(ObjectMapper objectMapper) { ... Jackson2HalModule.HalHandlerInstantiator instantiator = new Jackson2HalModule.HalHandlerInstantiator( HalObjectMapperConfiguration.this.relProvider, HalObjectMapperConfiguration.this.curieProvider); ... 这意味着调用Jackson2HalModule.HalHandlerInstantiator的两个参数Constructor.另一方面,在spring-hateoas-0.19.0.RELEASE.jar的Jackson2HalModule.HalHandlerInstantiator中,构造函数不幸只有3或4个参数: public class Jackson2HalModule extends SimpleModule { ... public static class HalHandlerInstantiator extends HandlerInstantiator { ... public HalHandlerInstantiator(RelProvider resolver, CurieProvider curieProvider, MessageSourceAccessor messageSource) { ... } public HalHandlerInstantiator(RelProvider resolver, CurieProvider curieProvider, MessageSourceAccessor messageSource, boolean enforceEmbeddedCollections) { ... } //no further constructors 我尝试过更新,不稳定的Spring Boot版本,但这也行不通.我不想使用较低版本的Spring HATEOAS,因为在这种情况下会发生其他错误. 你知道是否有任何解决方法?
...全文
52 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38078536 2019-09-12
  • 打赏
  • 举报
回复
我使用1.2.5.RELEASE与0.19.0.RELEASE没有任何错误.升级了一些像这样的依赖: <properties> <spring-data-releasetrain.version>Gosling-RELEASE</spring-data-releasetrain.version> <spring-hateoas.version>0.19.0.RELEASE</spring-hateoas.version> <jackson.version>2.6.1</jackson.version> </properties>

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧