2017-05-01 20 views
0

Spring Social 1.1.4とJava8も使用するSpring MVC Webアプリケーション用に、Spring 4.3.1からSpring 4.3.8に更新しようとしました。 これはエラーで起動時に失敗しました:春のソーシャルビーンはSpring 4.3.5に登録されていません

Error creating bean with name 'MySocialConfig': Unsatisfied 
dependency expressed through method 'setSocialConfigurers' parameter 0; nested exception is 

org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No qualifying bean of type ' java.util.List<org.springframework.social.config.annotation.SocialConfigu rer>' available: 
expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} 

は限り4.3.4は大丈夫だったとして更新します。ただし、このエラーが発生した場合、Beanの初期化時に4.3.5以上のバージョンは失敗します。

そして、ここに私の社会Configクラスである:4.3.5以降を春に更新するとき

@Configuration 
@EnableSocial 
public class MySocialConfig extends SocialConfiguration implements SocialConfigurer { 
     // some methods implemented according to SpringSocial docs: 
    E.g. 

    @Override 
    public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {  
     configureXXX(cfConfig); 
     configureYYY(cfConfig); 
    } 
    } 

は@Configurationクラスで誰遭遇した問題を抱えていますか?おかげ リチャード

+0

の良い例です。 (これは既に@EnableSocialによって既にインポートされており、基本的にここでは冗長です)。または '@ EnableSocial'を削除してください。問題はあなたがBeanを自分自身に注入していることです(構成に 'SocialConfigurer'が必要ですが、それ自体は' SocialConfiguration'です)。基本的には循環依存性です –

+0

それはうまくいきました。 – otter606

答えて

1

あなたはSocialConfigurerAdapterを拡張することができますこれに代えて(あなたはSocialConfigurationで定義されたSpring MVCの構成は、インポート持って@Configurationクラスにこの注釈を追加するために使用されます@EnableSocialを使用しているため。)SocialConfigurationを拡張する必要はありません - >

@Configuration 
@EnableSocial 
public class SocialConfig extends SocialConfigurerAdapter { 

    @Autowired 
    private DataSource dataSource; 

    @Override 
    public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment environment) { 
     connectionFactoryConfigurer.addConnectionFactory(new GitHubConnectionFactory(
       environment.getProperty("spring.social.github.appId"), 
       environment.getProperty("spring.social.github.appSecret"))); 

     connectionFactoryConfigurer.addConnectionFactory(new TwitterConnectionFactory(
       environment.getProperty("spring.social.twitter.consumerKey"), 
       environment.getProperty("spring.social.twitter.consumerSecret"))); 

     connectionFactoryConfigurer.addConnectionFactory(new KakaoConnectionFactory(
       environment.getProperty("spring.social.kakao.appId"))); 
    } 

    @Override 
    public UserIdSource getUserIdSource() { 
     return new AuthenticationNameUserIdSource(); 
    } 

    @Override 
    public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) { 
     JdbcUsersConnectionRepository repository = new JdbcUsersConnectionRepository(dataSource, connectionFactoryLocator, Encryptors.noOpText()); 
     return repository; 
    } 

    @Bean 
    public ConnectController connectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository) { 
     return new ConnectController(connectionFactoryLocator, connectionRepository); 
    } 

    @Bean 
    public ProviderSignInUtils providerSignInUtils(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository) { 
     return new ProviderSignInUtils(connectionFactoryLocator, usersConnectionRepository); 
    } 
} 

Here私は `あなたのクラスからSocialConfiguration`を拡張取り除くと言うでしょう春のソーシャル

+0

ありがとうございました - 私はSocialConfigurationから拡張していましたが、その中のメソッドをオーバーライドしたいのですが、少なくとも問題の原因を知っていて、サブクラスの依存関係を取り除くことができます。私はもはや満たされていない依存エラーを見ていません。 – otter606

関連する問題