首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法解决EnableTwitter和EnableFacebook问题

无法解决EnableTwitter和EnableFacebook问题
EN

Stack Overflow用户
提问于 2014-07-26 19:53:46
回答 1查看 347关注 0票数 0

我正在尝试将我当前的spring项目与Twitter和Facebook连接起来,为此,我遵循这两篇文章的说明:

因此,我将这两个类添加到我的项目中:

TwitterConfig.java

代码语言:javascript
复制
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

代码语言:javascript
复制
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中:

代码语言:javascript
复制
<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还是无法解决。

有人能说出这是怎么回事吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-27 10:24:46

@EnableTwitter和类似的不再存在。

通用@EnableSocial现在就在那里。SocialConfigurer是由您来实现的。

对,这些行会应该更新,我们已经注意到了。

更多信息,您可以从参考手册找到。

谢谢你再指出一次。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24974990

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档