【发布时间】:2021-06-16 08:41:59
【问题描述】:
我在 springboot 应用程序中配置了两个 ObjectMapper。我在如下配置类中声明它们:
@Configuration
public class Config {
@Bean
@Primary
public ObjectMapper getPrimary() {
return new ObjectMapper();
}
@Bean
public ObjectMapper getSecondary() {
return new ObjectMapper();
}
}
@Primary ObjectMapper 可以正常工作。我不知道如何让 @RestController 使用辅助 ObjectMapper。任何帮助表示赞赏。
【问题讨论】:
标签: json spring spring-boot jackson spring-restcontroller