2014-07-26 43 views
0

我試圖連接與Twitter和Facebook我目前的Spring項目,爲此我下面從這兩個職位的說明:EnableTwitter和EnableFacebook解決不了

因此,我將這兩個類添加到我的項目中:

TwitterConfig.java

import org.springframework.context.annotation.Bean; 
import org.springframework.social.UserIdSource; 
import org.springframework.social.connect.ConnectionFactoryLocator; 
import org.springframework.social.connect.ConnectionRepository; 
import org.springframework.social.connect.web.ConnectController; 
import org.springframework.social.twitter.config.annotation.EnableTwitter; 
import org.springframework.social.config.annotation.EnableInMemoryConnectionRepository; 

@EnableTwitter(appId="...", appSecret="...") 
@EnableInMemoryConnectionRepository 
public class TwitterConfig { 

    @Bean 
    public UserIdSource userIdSource() { 
     return new UserIdSource() { 
      @Override 
      public String getUserId() { 
       return "testuser"; 
      } 
     }; 
    } 

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

} 

FacebookConfig.java

import org.springframework.context.annotation.Bean; 
import org.springframework.social.UserIdSource; 
import org.springframework.social.connect.ConnectionFactoryLocator; 
import org.springframework.social.connect.ConnectionRepository; 
import org.springframework.social.connect.web.ConnectController; 
import org.springframework.social.facebook.config.annotation.EnableFacebook; 
import org.springframework.social.config.annotation.EnableInMemoryConnectionRepository; 

@EnableFacebook(appId="...", appSecret="...") 
@EnableInMemoryConnectionRepository 
public class FacebookConfig { 

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

    @Bean 
    public UserIdSource userIdSource() { 
     return new UserIdSource() { 
      @Override 
      public String getUserId() { 
       return "testuser"; 
      } 
     }; 
    } 

} 

,並添加我的pom.xml此行:

<dependency> 
    <groupId>org.springframework.social</groupId> 
    <artifactId>spring-social-facebook</artifactId> 
    <version>1.1.0.RELEASE</version> 
</dependency> 
<dependency> 
    <groupId>org.springframework.social</groupId> 
    <artifactId>spring-social-twitter</artifactId> 
    <version>1.1.0.RELEASE</version> 
</dependency> 
<dependency> 
    <groupId>org.springframework.social</groupId> 
    <artifactId>spring-social-core</artifactId> 
    <version>1.1.0.RELEASE</version> 
</dependency> 
<dependency> 
    <groupId>org.springframework.social</groupId> 
    <artifactId>spring-social-config</artifactId> 
    <version>1.1.0.RELEASE</version> 
</dependency> 

但是,儘管這一切,註釋EnableTwitter,EnableFacebook和EnableInMemoryConnectionRepository canoot解決。

任何人都可以說這裏有什麼問題嗎?

回答

0

@EnableTwitter以及類似搜索不再存在。

通用@EnableSocial現在在那裏。而SocialConfigurer是爲你實現的。

對,這些guildes應該更新,這是我們的雷達。

更多信息,你可以從Reference Manual

找到謝謝你指出這一個課堂作品。