2016-09-07 8 views
0

私たちはセキュリティ機構としてoauth2を持つマイクロサービスを使用しています。 我々はこのようなOAuth2RestTemplateと他のmicroservicesを呼び出している瞬間:spring cloud sleuthとOauth2Template

template.postForObject("http://"+MY_DISCOVERY_NAME+"/path/to/restservice", params, Void.class); 

我々は次のようにOAuth2RestTemplateを注入する@Autowiredを使用している:

@Configuration 
    public class ApplicationConfig { 

     @Autowired 
     OAuth2RestTemplate oauth2Resttemplate; 
     ... 
     @Bean 
     public MyBean getMyBean() { 
      MyBeanImpl myBean = new MyBeanImpl(); 
      oauth2Resttemplate.setErrorHandler(getErrorHandler()); 
      myBean.setTemplate(oauth2Resttemplate); 
      return myBean; 
     } 
     ... 
    } 

だから、私たちのために次のステップは、呼び出しを行うことですtracable 。 春の雲を使いたいです。

Caused by: java.lang.IllegalArgumentException: Can not set org.springframework.security.oauth2.client.OAuth2RestTemplate 

でorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor:その春はもうOAuth2RestTemplateをautowireすることができません

<dependency> 
     <groupId>org.springframework.cloud</groupId> 
     <artifactId>spring-cloud-starter-sleuth</artifactId> 
    </dependency> 

した後、次のように

は、だから私は、依存関係を追加しましたIllegalArgumentExceptionがスローされる:

  @Override 
      protected void inject(Object bean, String beanName, PropertyValues pvs) throws Throwable { 
       ... 

          } 
          if (value != null) { 
            ReflectionUtils.makeAccessible(field); 
            field.set(bean, value); 
          } 
        } 
       ... 

例外は次のfield.set(bean, value);結果:

java.lang.IllegalArgumentException: Can not set org.springframework.security.oauth2.client.OAuth2RestTemplate field my.package.ApplicationConfig.oauth2Resttemplate to com.sun.proxy.$Proxy120 

がどのように私は探偵との組み合わせでOAuth2RestTemplate使用することができますか?

おかげ

マックス

+0

これは興味深い...サンプルをどこかに投稿できますか?また、より多くのスタックトレースを投稿できますか? –

答えて

0

は、問題は、私は、インタフェースOAuth2RestOperationsの代わりにOAuth2RestTemplateを有線ということでした。

OAuth2RestOperationsのワイヤリングは私の仕事です。

関連する問題