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解決。
任何人都可以說這裏有什麼問題嗎?