gpt4 book ai didi

Jhipster 上的 java.lang.NoSuchMethodError

转载 作者:行者123 更新时间:2023-12-01 09:55:24 29 4
gpt4 key购买 nike

我从 spring-boot 项目发送restTemplate.exchange():

RestTemplate restTemplate = new RestTemplate();
String URI = "http://localhost:8888/getResource";
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
ResponseEntity<List<PayScreenMenu>> screenMenus = restTemplate.exchange(URI, HttpMethod.GET, null, new ParameterizedTypeReference<List<PayScreenMenu>>() {});

到jhipster方法:

@RequestMapping(value = "/getResource", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody List<PayScreenMenu> getResource() {
....
return payScreenMenuList;
}

返回jhipster方法后返回错误:

java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.introspect.AnnotatedMember.getType()Lcom/fasterxml/jackson/databind/JavaType;

在 pom.xml jhipster 项目上添加了版本 jackson 转换器:

        <dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate4</artifactId>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hppc</artifactId>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.7.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-json-org</artifactId>
<version>2.6.4</version>
</dependency>

最佳答案

JHipster 方法所在的 Resource 类可能带有如下注释:

@RestController
@RequestMapping("/api")

如果是这种情况,您需要将 String URI = "http://localhost:8888/getResource"; 更改为 String URI = "http://localhost:8888/api/getResource";.

关于Jhipster 上的 java.lang.NoSuchMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37279576/

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