I want to use the latest stable version 0.19.0.RELEASE
of Spring HATEOAS
. I combine it with the latest stable version 1.2.6.RELEASE
of Spring Boot
. In the build.gradle
we find among others
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'
}
When I start the main application, I get the exception
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:...)
That looks terrible, but we can translate it. On the one hand, in org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration
of spring-boot-autoconfigure-1.2.6.RELEASE.jar
we find
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);
...
That means the two argument Constructor of Jackson2HalModule.HalHandlerInstantiator
is called. On the other hand, in Jackson2HalModule.HalHandlerInstantiator
of spring-hateoas-0.19.0.RELEASE.jar
the constructors unfortunately have only 3 or 4 arguments:
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
I have tried newer, not stable Spring Boot
versions, but this does not work, either. I don't want to use a lower version of Spring HATEOAS
, because in this case other errors occur.
Do you know if there is any workaround?