I have a BuiltInComponents implementation like this:
import play.core.ObjectMapperComponents;
...
final class MyComponents extends BuiltInComponentsFromContext
implements HttpFiltersComponents, AssetsComponents,
AhcWSComponents, EhCacheComponents, ObjectMapperComponents {
...
@Override
public ObjectMapper objectMapper() {
ObjectMapper mapper = Json.newDefaultMapper()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.registerModule(new Jdk8Module());
Json.setObjectMapper(mapper);
applicationLifecycle().addStopHook(() -> {
Json.setObjectMapper(null);
return CompletableFuture.completedFuture(null);
});
return mapper;
}
...
}
The compiler is yelling at me: "MyComponents is not abstract and does not override abstract method applicationLifecycle() in play.core.ObjectMapperComponents".
I believe that's because applicationLifecycle() in ObjectMapperComponents returns play.api.inject.ApplicationLifecycle; but in BuiltInComponentsFromContext the applicationLifecycle() method returns play.inject.ApplicationLifecycle. What to do?
Am I going about setting up the custom ObjectMapper in the right way?