优化OnlyOffice配置,修复ObjectMapper Bean导致原项目PUT相关接口报JSON反序列化失败问题

This commit is contained in:
liangwen 2025-09-11 14:27:36 +08:00
parent b5642ebfdc
commit 1e1ad28fc1

View File

@ -18,6 +18,7 @@
package com.ruoyi.file.config.onlyoffice; package com.ruoyi.file.config.onlyoffice;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.file.office.documentserver.storage.FileStoragePathBuilder; import com.ruoyi.file.office.documentserver.storage.FileStoragePathBuilder;
import com.ruoyi.file.office.documentserver.util.SSLUtils; import com.ruoyi.file.office.documentserver.util.SSLUtils;
@ -28,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@ -78,8 +80,15 @@ public class OnlyofficeConfiguration {
} }
} }
// @Bean
// public ObjectMapper objectMapper(){ // create the object mapper
// return new ObjectMapper();
// }
@Bean @Bean
public ObjectMapper objectMapper(){ // create the object mapper public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
return new ObjectMapper(); ObjectMapper mapper = builder.createXmlMapper(false).build();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper;
} }
} }