在邮递员中,我可以通过以下方式通过查询 influxDb 成功执行以下 rest api:
https://test-jon.alice.it:58799/query?db=edms_db&q=SELECT * FROM M_M WHERE time> now () - 6m LIMIT 5
现在,在我的 spring boot 项目中,我试图以这种方式在 feign 客户端界面中使用它:
@FeignClient(name = "feignClient", url = "https://edms-dev.aceaspa.it:30223")
public interface FeignClientInfluxDB {
@SuppressWarnings("rawtypes")
@RequestMapping(method = RequestMethod.GET, value = "/query?db=edms_db&q=SELECT * FROM Monterotondo_Marittimo WHERE time > now() - 6m LIMIT 5")
List<M_MEntity> getAllDataFromInfluxDBwithTimeCondiction(
@RequestHeader(name = "Authorization") String token);
}
这是我的 Service 类中使用 feignClient 方法的 getAll 方法:
@Transactional
public List<M_MEntity> getAllWithFeignClientWithTimeCondiction() throws Exception {
final String methodName = "getAllWithFeignClientWithCondiction()";
try {
this.startLog(methodName);
List<M_MEntity> result = new ArrayList<M_MEntity>();
String token = getToken();
result = feignClient.getAllDataFromInfluxDBwithTimeCondiction(token);
logger.info("Request Successful");
if (!result.isEmpty()) {
for (M_MEntity m_MEntity: result) {
M_MEntityPstgrs m_MEntityPstgrs = new M_MEntityPstgrs();
m_MEntityPstgrs = ConvertersUtils
.createM_MEntityPstgrs FromM_MEntity(
m_MEntity);
mMDao.save(m_MEntityPstgrs);
logger.info("Table Updated");
}
}
this.endLog(methodName, result);
return result;
} catch (final Exception e) {
logger.error(e.getMessage());
this.errorLog(methodName, e);
throw e;
}
}
但是当我尝试从我的服务类中执行其中一个 get 方法时,我得到了这个异常:
feign.codec.DecodeException: Error while extracting response for type [java.util.List<com.simplemicroservice.database.influx.entity.M_MEntity>] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.util.ArrayList<com.nttdata.iot.simplemicroservice.database.influx.entity.M_MEntity>` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList<com.nttdata.iot.simplemicroservice.database.influx.entity.M_MEntity>` out of START_OBJECT token