I believe Jackson Auto Configuration in Spring should set ConstructorDetector.USE_PROPERTIES_BASED flag out of the box:
objectMapper.setConstructorDetector(com.fasterxml.jackson.databind.cfg.ConstructorDetector.USE_PROPERTIES_BASED);
Background can be found here: https://github.com/FasterXML/jackson-databind/issues/1498 and my tldr version is (I've been involved since the start of this in 2014...): Due to backwards compatibility concerns this can't be changed in Jackson itself but on the other hand this surprises a lot of Jackson users as the whole Java industry moves slowly forward to immutable by default way of thinking.
With this enabled users should be able to deserialize classes without any exceptions or surprises:
class Foo {
private final Bar bar;
Foo(Bar bar) {
this.bar = bar;
}
}
Comment From: philwebb
We discussed this today on a team call and we're currently not keen to change the default. We think it's best if we keep ourselves aligned with the Jackson defaults as much as possible. Perhaps Jackson will reconsider the default on 3.0?
We do think it's worth making it easier to change the setting for those that wish to. I've opened #27178 to see if we can add a new property for that.