我该如何解决 com.fasterxml.jackson.databind.exc.

我在尝试通过 Swagger 发布请求时收到以下错误。当我通过邮递员这样做时,这很好。


我使用的是弹簧靴版本 = “2.1.0.发布”, 摇摆版本 = '2.9.2'。


这是我的 Json 映射类。数据导出.java


@XmlRootElement(name = "DataExport")

public class DataExport

{

  @JsonProperty("engineName")

  private String engineName;


  @JsonProperty("searchQuery")

  private String searchQuery;


  public DataExport()

  {

    super();

  }


  public DataExport(String aEngineName, String aSearchQuery)

  {

    super();

    this.engineName = aEngineName;

    this.searchQuery = aSearchQuery;

  }

RestController.java


@RequestMapping(value = "/export", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.TEXT_PLAIN_VALUE)

  @ApiOperation(authorizations = {

      @Authorization(value = "oauth") }, value = "Initiates the job for export", response = String.class)

  @ApiResponses({ @ApiResponse(code = 200, message = "Request accepted."),

      @ApiResponse(code = 500, message = "The export could not be started due to an internal server error.") })

  public String getJobId(@RequestBody DataExport aDataExport, HttpServletResponse aResponse,

      @Value("${com.xyz.dataexportmodule.defaultfilelocation}") final String aLocation)

      throws Exception

  {

    LOG.info("Initializing export for Engine {} and Query {}", aDataExport.getEngineName(),

        aDataExport.getSearchQuery());


    String exportLocation = aLocation

....

我想传递这个 json { “引擎名称”:“ABC”,“搜索查询”:“*”


}


但是我得到这个错误:


nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.xyz.dataexportmodule.persistence.entity.DataExport` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('string')

 at [Source: (PushbackInputStream); line: 1, column: 1]]

我无法弄清楚问题所在,有人请帮忙。


慕少森
浏览 248回答 1
1回答

吃鸡游戏

您的屏幕截图显示您有两个身体,这是无法完成的。我不知道你想做什么,但只是为了测试删除字段aLocation,它会没事的。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java