Utiliser spring cloud feign provoque java.lang.Noclassdeffonderror: feign/Logger

j'ai activé mon nuage de printemps pour feignClients comme ceci:

@Configuration
@EnableAutoConfiguration
@RestController
@EnableEurekaClient
@EnableCircuitBreaker
@EnableFeignClients

public class SpringCloudConfigClientApplication {
}

mais au fur et à mesure que j'ajoute des entidefeignclients, j'ai eu cette erreur lors de la compilation,

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)

Mon POMPON est

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

afin de résoudre le problème de feign logger, quelle autre dépendance dois-je ajouter à la POM?

Merci

Merci @spencergibb, basé sur votre suggestion, ça a marché après que j'ai changé mon pom. Maintenant, J'ai un autre problème pour utiliser FeignClient. Veuillez voir ci-dessous:

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

et l'interface est:

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

Le magasin entité est:

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

maintenant, quand je récupère dans URL, j'ai cette erreur,

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

semblait que l'erreur ici est récupéré la liste ne peut pas être convertie en classe de magasin. Donc, afin d'utiliser FeignClient, n'importe quel autre mapper que nous devons inclure pour convertir JSON en objets?

Merci

9
demandé sur spencergibb 2015-06-09 19:32:44

1 réponses

il Vous manque spring-cloud-starter-feign

22
répondu spencergibb 2015-06-09 16:46:14