java - @Inject Twitter bean 一个 connectionRepository 问题
问题描述
我正在开发一个将从 Twitter 获取数据的应用程序。首先,我创建了一个application.properties
包含消费者 ID 和机密的。其次,我创建了一个控制器并注入了 Twitter 和 ConnectionRepository。我按照Spring Getting Started Guide中的说明做了所有事情
但我收到以下错误。
@RestController
@RequestMapping("/api")
public class MarketDataResource {
private Twitter twitter;
private ConnectionRepository connectionRepository;
@Inject
public MarketDataResource(Twitter twitter, ConnectionRepository connectionRepository) {
this.twitter = twitter;
this.connectionRepository = connectionRepository;
}
@GetMapping("/market/data")
public String searchTweet (Model model) {
if (connectionRepository.findPrimaryConnection(Twitter.class) == null) {
return "redirect:/connect/twitter";
}
model.addAttribute(twitter.userOperations().getUserProfile());
CursoredList<TwitterProfile> friends = twitter.friendOperations().getFriends();
model.addAttribute("friends", friends);
return "hello";
}
}`
错误堆栈:
fr.softeam.group.stockpicking.web.rest.data.MarketDataResource 中构造函数的参数 0 需要一个无法找到的“org.springframework.social.twitter.api.Twitter”类型的 bean。行动:考虑在你的配置中定义一个“org.springframework.social.twitter.api.Twitter”类型的bean。
解决方案
推荐阅读
- django - 如何使用相同的 DATABASE_HOST 从 dockerized django 和 non-dockerized django 将 django 应用程序连接到 dockerized postgres db
- sql - 在不破坏顺序的情况下对列进行分组
- amazon-web-services - 亚马逊 Alexa 到 Raspberry Pi 通信
- python - 使用 pygame 在 Mac 上不显示屏幕
- vue.js - Vue:不响应命令
- c# - 如何从外部结构的对象访问嵌套结构的属性
- amazon-web-services - AWS HTTP Gateway:相同路由的多种方法,不包括使用无服务器框架的选项
- laravel - Laravel 自定义邮箱验证
- r - R计算日期差异时的函数错误
- c++ - Boost Python - 对`_Py_NoneStruct'的未定义引用