Since the 3.1.0-RC1 upgrade, in an unit test, when @SpyBean is used on an ObjectMapper, the ObjectMapper doesn't have any module registered.
When the ObjectMapper is instead simply @Autowired, it obviously can't be used directly as a spy but modules are registered as expected.
When downgrading back to 3.1.0-M2, @SpyBean and ObjectMapper work again together.
The repository of the demo can be found here.
Another demo without Spring Boot was done using the same dependencies versions as the Spring Boot one but this one works as expected. The repository of this other demo can be found here.
Comment From: maciejwalkowiak
Perhaps try upgrading to Mockito 5.3.1. There's a bug in 5.3.0 related to spies.
https://github.com/mockito/mockito/releases/tag/v5.3.1
Comment From: romainmoreau
Good catch, I couldn't think of trying that because it was working with Mockito 5.3.0 without Spring Boot but it fixes the issue indeed, thanks!