我正在开发一个使用java和spring social作为maven项目的twitter应用程序。当我运行代码时,它显示以下异常!!
我的java部分代码
Application.java
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application {
/*
* SPRING BOOTSTRAP MAIN
*/
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
HelloCantroller.java
package hello;
import java.util.List;
import javax.inject.Inject;
import org.springframework.social.connect.UserProfile;
import org.springframework.social.linkedin.api.LinkedIn;
import org.springframework.social.linkedin.api.LinkedInProfile;
import org.springframework.social.linkedin.api.impl.LinkedInTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/")
public class HelloController {
private LinkedIn linkedin;
UserProfile userProfile;
@Inject
public HelloController(LinkedIn linkedin) {
this.linkedin = linkedin;
}
@RequestMapping(method=RequestMethod.GET)
public String helloLinkedIn(Model model) {
if (!linkedin.isAuthorized()) {
return "redirect:/connect/linkedin";
}
LinkedInProfile profile = linkedin.profileOperations().getUserProfile();
String profileId = linkedin.profileOperations().getProfileId();
System.out.println(profileId);
return "hello";
}
}
Html网页
LinkedinConnect.html
<html>
<head>
<title>Hello LinkedIn</title>
</head>
<body>
<h3>Connect to LinkedIn</h3>
<form action="/connect/linkedin" method="POST">
<!-- <input type="hidden" name="scope" value="read_stream" /> -->
<div class="formInfo">
<p>You aren't connected to LinkedIn yet. Click the button to connect this application with your Facebook account.</p>
</div>
<p><button type="submit">Connect to Facebook</button></p>
</form>
</body>
</html>
LinkedInConnected.html
<html>
<head>
<title>Hello Facebook</title>
</head>
<body>
<h3>Connected to Facebook</h3>
<p>
You are now connected to your Facebook account.
Click <a href="/">here</a> to see some entries from your Facebook home feed.
</p>
</body>
</html>
如何解决上述错误并让我的代码可以运行?
答案 0 :(得分:0)
取消注释input type =“hidden”name =“scope”value =“read_stream” 因为模型将引用值read_stream
引用的地图对象