简体   繁体   English

Jhipster上的java.lang.NoSuchMethodError

[英]java.lang.NoSuchMethodError on Jhipster

I send restTemplate.exchange() from spring-boot project: 我从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>>() {});

to jhipster method: 到jhipster方法:

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

after the return jhipster method returned error: 返回jhipster方法后返回错误:

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

on pom.xml jhipster project added version jackson converter: 在pom.xml jhipster项目上添加了杰克逊转换器版本:

        <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>

The Resource class that the JHipster method is in might be annotated with something like: JHipster方法所在的Resource类可能带有以下注释:

@RestController
@RequestMapping("/api")

If that's the case, you need to change String URI = "http://localhost:8888/getResource"; 在这种情况下,您需要更改String URI = "http://localhost:8888/getResource"; to String URI = "http://localhost:8888/api/getResource"; String URI = "http://localhost:8888/api/getResource"; .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM