我从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>
答案 0 :(得分:1)
JHipster方法所在的Resource类可能会注释为:
@RestController
@RequestMapping("/api")
如果是这种情况,则需要将String URI = "http://localhost:8888/getResource";
更改为String URI = "http://localhost:8888/api/getResource";
。