spring社交xml配置

时间:2012-04-27 03:18:33

标签: spring spring-social xml-configuration

我已经阅读过spring社交文档,但配置部分是基于Java的,但我的项目配置是基于xml的。所以请告诉我如何在spring xml配置文件中配置spring spring。谢谢,对不起我的英语很差

3 个答案:

答案 0 :(得分:0)

发布您的代码和问题将有助于我们为您提供最佳解决方案。请参阅以下链接可能是您正在寻找的 http://harmonicdevelopment.tumblr.com/post/13613051804/adding-spring-social-to-a-spring-mvc-and-spring

答案 1 :(得分:0)

答案 2 :(得分:0)

您必须创建社交配置xml文件,并且必须导入到root-context.xml文件。此外,您可以考虑使用spring security配置您的应用程序。这取决于您的项目架构。

示例spring social xml配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:social="http://www.springframework.org/schema/social"
       xmlns:facebook="http://www.springframework.org/schema/social/facebook" xmlns:bean="http://java.sun.com/jsf/core"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
       http://www.springframework.org/schema/social http://www.springframework.org/schema/social/spring-social.xsd
       http://www.springframework.org/schema/social/facebook http://www.springframework.org/schema/social/spring-social-facebook.xsd">

<!-- Ensures that configuration properties are read from a property file -->
<context:property-placeholder location="file:${sampleapp.appdir}/conf/appparam.txt"/>

<!--
    Configures FB and Twitter support.
-->
<facebook:config app-id="${facebook.clientId}" app-secret="${facebook.clientSecret}" />

<!--
    Configures the connection repository. This application uses JDBC
    connection repository which saves connection details to database.
    This repository uses the data source bean for obtaining database
    connection.
-->
<social:jdbc-connection-repository data-source-ref="sampleappDS" connection-signup-ref="accountConnectionSignup"/>



<!--
   This bean is custom account connection signup bean for your registeration logic.
    -->
    <bean id="accountConnectionSignup" class="com.sampleapp.social.AccountConnectionSignup"></bean>

<!--
    This bean manages the connection flow between the account provider and
    the example application.
-->
<bean id="connectController" class="org.springframework.social.connect.web.ConnectController" autowire="constructor">
    <constructor-arg index="0" ref="connectionFactoryLocator"/>
    <constructor-arg index="1" ref="connectionRepository"/>
</bean>

示例root-context.xml:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:cache="http://www.springframework.org/schema/cache"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">

<!-- Scan for Spring beans declared via annotations. -->
<context:component-scan base-package="com.sampleapp"/>

<context:annotation-config/>

<context:property-placeholder location="file:${sampleapp.appdir}/conf/appparam.txt"/>

<cache:annotation-driven/>

<!-- Root Context: defines shared resources visible to all other web components -->
<import resource="security-config.xml"/>
<import resource="classpath*:spring/bean-context.xml"/>
<import resource="classpath*:spring/persistence-config.xml"/>
<import resource="social-config.xml"/>

<aop:aspectj-autoproxy proxy-target-class="true"/>