Skip to content

Instantly share code, notes, and snippets.

Last active May 7, 2020 12:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Yrwein/34dfc925ef383001efa43d4dfe1e5bec to your computer and use it in GitHub Desktop.
An example with Spring-Boot module auto-discovery
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.json.JsonTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
public class ModuleTest {
static class TestConfig {
public Module someModule() {
return new Module() {
public String getModuleName() {
return "somemodule";
public Version version() {
return new Version(1, 1, 1, "");
public void setupModule(SetupContext context) {
//@Bean // uncomment to disable module auto-discovery
public Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() {
return new Jackson2ObjectMapperBuilder();
private ObjectMapper objectMapper;
public void test() {
for (Object registeredModuleId : objectMapper.getRegisteredModuleIds()) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment