org.springframework.web.client.RestClientException:无法提取响应没有找到合适的HttpMessageConverter

时间:2016-07-10 16:00:04

标签: java json spring spring-boot couchdb

我使用spring boot从CouchDB视图中获取数据,一切正常,然后我将.json文件中视图提供的json内容复制并粘贴,并使用NodeJS将其提供到URL中,我知道得到以下错误消息:

org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class MyClass] and content type [application/octet-stream]

以下是发生错误的代码行:



RestTemplate myRestTemplate = new RestTemplate();
ResponseEntity<MyClass> loadRecordResponse = myRestTemplate.getForEntity("http://localhost:4000/", MyClass.class);
&#13;
&#13;
&#13;

以下是我在NodeJS中用来创建REST Web服务的代码:

&#13;
&#13;
var fs = require('fs');

var express = require('express');
var app = express();

app.get('/', function (req, res) {
   fs.readFile('D:\\Userfiles\\x\\Desktop\\Local CouchDB\\loads.json', 'utf8', function (err, data) {
       console.log( data );
       res.end( data );
   });
})

var server = app.listen(4000, function () {

  var host = server.address().address
  var port = server.address().port

  console.log("Example app listening at http://%s:%s", host, port)

})
&#13;
&#13;
&#13;

0 个答案:

没有答案