在 YAML 文件中设置 DEFAULT_VIEW_INCLUSION

5 spring json jackson

DEFAULT_VIEW_INCLUSION如何在 Spring中将属性设置为yml文件?

现在,我有这个

spring: jackson: mapper: DEFAULT_VIEW_INCLUSION: true

但不起作用。

cod*_*ent 2

尝试使用 Java 配置:

@Configuration
public class JacksonMapperConfig {

    @Bean
    public ObjectMapper objectMapper() {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, true);
        return mapper;
    }
}
Run Code Online (Sandbox Code Playgroud)