当前位置: 代码迷 >> 综合 >> SpringBoot获取Json格式请求报错com.fasterxml.jackson.databind.JavaType.isReferenceType()Z
  详细解决方案

SpringBoot获取Json格式请求报错com.fasterxml.jackson.databind.JavaType.isReferenceType()Z

热度:6   发布时间:2023-12-17 13:58:22.0

如果pom文件中存在此依赖,将其注释掉

<!--<dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-core</artifactId><version>2.5.2</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.5.2</version></dependency>-->

Cotroller代码

@Controller
@RequestMapping(value = "/ML")
public class MLModelCtronller {
    @RequestMapping(value = "/getPredic",produces = "application/json;charset=UTF-8",method = RequestMethod.POST)@ResponseBodypublic Object getPredict(@RequestBody Device device) {
    String a = device.getDay();String b = device.getTemperature();String c = device.getFlowSpeed();String d = device.getWaterPressure();if ((isValidateNumbers(a) && isValidateNumbers(b) && isValidateNumbers(c) && isValidateNumbers(d))) {
    return 12.2;}return null;}

然后使用PostMan测试

就可以输出结果啦

  相关解决方案