我使用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;
以下是我在NodeJS中用来创建REST Web服务的代码:
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;