spring social xml config

白昼怎懂夜的黑 提交于 2019-12-11 11:05:53

问题


i have already read the spring social document but the part of configuration is Java based, but my project's configuration is xml based. so please tell me how config spring social in spring xml config file. thank you and sorry for my poor english


回答1:


Posting your code and issues will help us to provide you the best solution. Refer to the link below may be that is what you are looking for http://harmonicdevelopment.tumblr.com/post/13613051804/adding-spring-social-to-a-spring-mvc-and-spring




回答2:


Take a look at the example xml config

https://github.com/SpringSource/spring-social-samples/tree/master/spring-social-showcase-xml/src/main/webapp/WEB-INF/spring




回答3:


You have to create a social config xml file and you have to import to your root-context.xml file. Also, you may think about configure your app with spring security. It's depends of your project architecture.

Sample spring social xml config file :

<?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>

Sample 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"/>



来源:https://stackoverflow.com/questions/10344316/spring-social-xml-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!