gpt4 book ai didi

java - Jackson版本不兼容?

转载 作者:行者123 更新时间:2023-12-01 14:50:16 31 4
gpt4 key购买 nike

我正在学习 Spring 的 REST。我使用 Maven 来实现项目依赖。

我正在使用 Spring 3.2.1 和 Jackson 进行 GETPOST 调用。当我使用 Jackson 1.5.6 版本时,GET 工作得很好,我可以看到从 GET 返回的对象的 Json 版本> 打电话。但是,当我升级到更新版本的 Jackson 时,它不再起作用,并且我在响应中返回以下内容...

The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().

查看 StackOverflow 上的其他问题,Jackson Mapper 和 Core 版本似乎存在问题,但我在我的项目中找不到其他对 Jackson 的引用,所以我认为这不是问题所在。

应用程序上下文包含以下内容...

    <mvc:annotation-driven/>

<context:component-scan base-package="im.poz.springrestserver" />

Controller 中调用的方法如下...

    @RequestMapping(value = "/clients/{clientid}", method= RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
@ResponseBody

public Client getClient(@PathVariable("clientid") int clientId) throws llegalArgumentException {
Client client=services.retrieveClientById(clientId);
return client;
}

@RequestMapping(value = "/clients", method= RequestMethod.POST, produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
@ResponseBody
public Client updateClient(@RequestBody Client client) throws IllegalArgumentException {

client=services.updateClient(client);
return client;

}

最佳答案

答案就在构建中。

我正在使用 IntelliJ Idea 11.1,对新构建的 Maven POM 的更改似乎没有反射(reflect)在部署的镜像中,因此更改 Jackson 版本意味着 Jackson 实际上在部署的构建中完全缺失。

我需要修改工件并重新部署。

问题已解决。

关于java - Jackson版本不兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14956054/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com