Java 无法解析EnableTwitter和EnableFacebook
我正在尝试将我目前的spring项目与Twitter和Facebook连接起来,为此,我遵循以下两篇文章的说明:Java 无法解析EnableTwitter和EnableFacebook,java,facebook,spring,api,twitter,Java,Facebook,Spring,Api,Twitter,我正在尝试将我目前的spring项目与Twitter和Facebook连接起来,为此,我遵循以下两篇文章的说明: 因此,我将这两个类添加到我的项目中: TwitterConfig.java import org.springframework.context.annotation.Bean; import org.springframework.social.UserIdSource; import org.springframework.social.connect.Connectio
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);
}
}
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";
}
};
}
}
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.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);
}
}
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";
}
};
}
}
并在my 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>
org.springframework.social
春季社交facebook
1.1.0.1发布
org.springframework.social
春季社交推特
1.1.0.1发布
org.springframework.social
春季社会核心
1.1.0.1发布
org.springframework.social
spring社交配置
1.1.0.1发布
但尽管如此,Twitter、Facebook和MemoryConnectionRepository的注解仍然无法解决
任何人都可以说这里出了什么问题?
@EnableTwitter
和类似的功能不再存在
通用的@EnableSocial
现在已经存在。而SocialConfigurer
则由您来实施
对,那些行会应该更新,它在我们的雷达上
更多信息可从
谢谢你再次指出