spring social
几周前,我写了一篇
文章,展示了我认为可以使用Spring Social编写的最简单的应用程序。 该应用程序读取并显示了Twitter用户的公共数据,并被编写为Spring Social和社交编码领域的介绍。 但是,让您的应用程序显示用户的公共数据只是故事的一半,而且在大多数情况下,您将需要显示用户的私有数据。
在本博客中,我将介绍您需要在应用程序的一两个页面上显示用户的Facebook或其他软件即服务(SaaS)提供程序数据的情况。 这里的想法是尝试演示最小的和最简单的操作,您可以将Spring Social添加到需要用户登录Facebook或其他SaaS提供商的应用程序中。
创建应用
要创建该应用程序,第一步是使用SpringSource Toolkit仪表板的模板部分创建一个基本的Spring MVC项目。 这提供了一个Web应用程序,可帮助您入门。
下一步是通过添加以下依赖项来设置pom.xml :
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>${org.springframework.security.crypto-version}</version>
</dependency>
<!-- Spring Social -->
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
<version>${spring-social.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-web</artifactId>
<version>${spring-social.version}</version>
</dependency>
<!-- Facebook API -->
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-facebook</artifactId>
<version>${org.springframework.social-facebook-version}</version>
</dependency>
<!-- JdbcUserConfiguration -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.159</version>
</dependency>
<!-- CGLIB, only required and used for @Configuration usage: could be removed in future release of Spring -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2</version>
</dependency>
…显然,您还需要在文件的%lt; properties />部分中添加以下内容:
<spring-social.version>1.0.2.RELEASE</spring-social.version>
<org.springframework.social-facebook-version>1.0.1.RELEASE</org.springframework.social-facebook-version>
<org.springframework.security.crypto-version>3.1.0.RELEASE</org.springframework.security.crypto-version>