2014-07-26 42 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

找到谢谢你指出这一个课堂作品。