java - 我正在从一项服务连接到另一个面临的转换问题
问题描述
我的代码:
final MultiValueMap<String, String> parts = new LinkedMultiValueMap<String, String>();
parts.add( "fileName", fileName );
HttpHeaders xmlHeaders = new HttpHeaders();
xmlHeaders.setContentType( MediaType.APPLICATION_XML );
HttpEntity<Resource> xmlEntity = new HttpEntity<Resource>( new FileSystemResource( file ), xmlHeaders );
parts.add( "file", xmlEntity );
final String url = baseurl+url;
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>( parts, createHttpHeadersWithToken() );
String response= restTemplate.exchange( url, HttpMethod.POST, requestEntity, String.class );
例外
调用后配置文件时发生异常:{} org.springframework.http.converter.HttpMessageConversionException:类型定义错误:[简单类型,类 java.nio.channels.Channels$1];嵌套异常是 com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class java.nio.channels.Channels$1 and no properties found to create BeanSerializer(为避免异常,禁用 SerializationFeature.FAIL_ON_EMPTY_BEANS)(通过引用链: org.springframework.util.LinkedMultiValueMap["file"]->java.util.LinkedList[0]->org.springframework.http.HttpEntity["body"]->org.springframework.core.io.FileSystemResource["outputStream "])
解决方案
推荐阅读
- powerbi-desktop - 如何在 Power BI 的堆积条形图中删除总计
- botframework - Microsoft 框架 BOT 的消息传递端点
- javascript - 使用带时间轴的 ECharts visualMap
- reactjs - InputField onChange 显示错误“字段应该是可变的”
- c - 如何使用 Linux Netlink 套接字监视输入设备的添加和删除
- python - 错误处理不适用于 Python 中的 Selenium 异常
- flask - 尽管使用生产配置,Flask 应用程序仍处于开发模式?
- excel - 在 Excel VBA 问题中打开超链接
- swift - SwiftUI 在单个 ScrollView 中嵌套 LazyVStacks
- xcode - XCode Preview Canvas 不工作:文件不在源代码控制之下