我正在尝试将我当前的spring项目与Twitter和Facebook连接起来,为此,我遵循这两篇文章的说明:
因此,我将这两个类添加到我的项目中:
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还是无法解决。
有人能说出这是怎么回事吗?
发布于 2014-07-27 10:24:46
@EnableTwitter和类似的不再存在。
通用@EnableSocial现在就在那里。SocialConfigurer是由您来实现的。
对,这些行会应该更新,我们已经注意到了。
更多信息,您可以从参考手册找到。
谢谢你再指出一次。
https://stackoverflow.com/questions/24974990
复制相似问题