2017-04-04 5 views
1

次のようにMavenのプロジェクトで私のサービスのPOMファイル:次のようになぜ@HystrixCommandは注入されたスプリングの注釈であり、失敗しましたか?

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 

<groupId>hello</groupId> 
<artifactId>reading</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>jar</packaging> 

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.5.2.RELEASE</version> 
    <relativePath/> <!-- lookup parent from repository --> 
</parent> 

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <java.version>1.8</java.version> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>org.springframework.cloud</groupId> 
     <artifactId>spring-cloud-starter-hystrix</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 
</dependencies> 

<dependencyManagement> 
    <dependencies> 
     <dependency> 
      <groupId>org.springframework.cloud</groupId> 
      <artifactId>spring-cloud-dependencies</artifactId> 
      <version>Camden.SR5</version> 
      <type>pom</type> 
      <scope>import</scope> 
     </dependency> 
    </dependencies> 
</dependencyManagement> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
     </plugin> 
    </plugins> 
</build> 


</project> 

そして、私のサービスの一部のソースコード:

@HystrixCommand(fallbackMethod = "reliable") 
public String readingList(){ 
    URI uri = URI.create("http://localhost:8090/recommended"); 

    return this.restTemplate.getForObject(uri, String.class); 
} 

私の質問をされ、私はcom.netflix.hystrix.contrib.javanica.annotation.HystrixCommandをインポートするときに、それを認識されません。誰もがこの同じ問題に遭遇しましたか?

どのように解決したのか教えてください。

ありがとうございました。

答えて

0

最新のPOMファイルによれば、それはspring-cloud-starter-netflix-hystrixの方が推奨されていません。 STSはインポートを追加するのにも役に立たなかったので、手動で追加する必要があります。

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 
関連する問題