I'm developing an application which will get data from Twitter.
First I created an application.properties
that contains the consumer ID and secret. Second I created a controller and injected Twitter and ConnectionRepository. I did everything as explained in the Spring Getting Started Guide
But I'm getting the error below.
@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";
}
}`
Error stack:
Parameter 0 of constructor in fr.softeam.group.stockpicking.web.rest.data.MarketDataResource required a bean of type 'org.springframework.social.twitter.api.Twitter' that could not be found. Action: Consider defining a bean of type 'org.springframework.social.twitter.api.Twitter' in your configuration.