使用spring cloud fake会导致java.lang.NoClassDefFoundError: feign/



我为feignClients启用了spring cloud:

@Configuration
@EnableAutoConfiguration
@RestController
@EnableEurekaClient
@EnableCircuitBreaker
@EnableFeignClients
public class SpringCloudConfigClientApplication {
}

但是当我添加enableFeignClients时,我在编译过程中得到了这个错误,

java.lang.NoClassDefFoundError: feign/Logger
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
    at java.lang.Class.getDeclaredMethods(Class.java:1962)

My POM is

<parent>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-parent</artifactId>
        <version>1.0.0.RELEASE</version>
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <start-class>demo.SpringCloudConfigClientApplication</start-class>
        <java.version>1.7</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
        </dependency>
    </dependencies>

为了解决伪日志记录器问题,我需要向POM添加哪些其他依赖项?

感谢

谢谢你@spencergibb,根据你的建议,在我换了我的诗歌后,它起作用了。现在我有另一个问题使用FeignClient。

@Autowired
    StoreClient storeClient;
    @RequestMapping("/stores")
    public List<Store> stores() {
        return storeClient.getStores();
    }

和接口是:

@FeignClient("store")
public interface StoreClient {
    @RequestMapping(method = RequestMethod.GET, value = "/stores")
    List<Store> getStores();
}

存储实体为:

public class Store {
    private long id;
    private String name;
    private String zip;
    public Store(long id, String name, String zip) {
        this.id = id;
        this.name = name;
        this.zip = zip;
    }
}

检索URL时,出现了这个错误,

ue Jun 09 15:30:10 PDT 2015
There was an unexpected error (type=Internal Server Error, status=500).
Could not read JSON: No suitable constructor found for type [simple type, class demo.entity.Store]: can not instantiate from JSON object (need to add/enable type information?) at [Source: java.io.PushbackInputStream@7db6c3dc; line: 1, column: 3] (through reference chain: java.util.ArrayList[0]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class demo.entity.Store]: can not instantiate from JSON object (need to add/enable type information?) at [Source: java.io.PushbackInputStream@7db6c3dc; line: 1, column: 3] (through reference chain: java.util.ArrayList[0])

似乎这里的错误是检索列表不能转换为存储类。因此,为了使用FeignClient,我们需要包含任何其他映射器来将JSON转换为对象吗?

谢谢

您缺少spring-cloud-starter-feign

相关内容

  • 没有找到相关文章

最新更新