How-to configure Spring Social via XML

前端 未结 2 1422
温柔的废话
温柔的废话 2021-02-04 15:35

I spend a few hours trying to get Twitter integration to work with Spring Social using the XML configuration approach. All the examples I could find on the web (and on stackover

相关标签:
2条回答
  • 2021-02-04 15:57

    I have a configuration that worked for Spring Social Facebook integration. (I have twitter configuration in it, But I haven't tested the twitter part in it)

    <bean class="org.springframework.social.connect.web.ProviderSignInController">
    <!-- relies on by-type autowiring for the constructor-args -->    
    <constructor-arg ref="signInAdapter" /> 
    </bean>
    
    <bean id="connectionFactoryLocator" 
      class="org.springframework.social.connect.support.ConnectionFactoryRegistry">
    <property name="connectionFactories">
        <list>
            <bean class="org.springframework.social.twitter.connect.TwitterConnectionFactory">
                <constructor-arg value="${twitter.consumerKey}" />
                <constructor-arg value="${twitter.consumerSecret}" />               
            </bean>
            <bean class="org.springframework.social.facebook.connect.FacebookConnectionFactory">
                <constructor-arg value="${facebook.clientId}" />
                <constructor-arg value="${facebook.clientSecret}" />                
            </bean>
        </list>
    </property>
    </bean>
    
    <bean id="connectionRepository" factory-method="createConnectionRepository" 
      factory-bean="usersConnectionRepository" scope="request">
    <constructor-arg value="#{request.userPrincipal.name}" />
    <aop:scoped-proxy proxy-target-class="false" />
    </bean>
    
    <bean id="signInAdapter" class="com.test.social.SimpleSignInAdapter"/>
    
    <bean id="usersConnectionRepository" 
      class="org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository">
    <constructor-arg ref="dataSource" />
    <constructor-arg ref="connectionFactoryLocator" />
    <constructor-arg ref="textEncryptor" />
    </bean>
    
    <bean id="textEncryptor" class="org.springframework.security.crypto.encrypt.Encryptors" 
            factory-method="noOpText" />
    

    I have primarily referred the documentation which is small enough to read and a tutorial which had more to do with integration with spring security. I hope this helps in some way.

    0 讨论(0)
  • 2021-02-04 16:02

    I have a working xml spring-mvc/spring-social configuration for tomcat7 in this question I posted.

    This question was posted a long time ago but maybe the configuration in my post will save some people some time. It took me quite some time to set up with XML configuration and latest spring 4.2.4 MVC including spring-social(1.1.4) and spring-social-twitter(1.1.2) twitter connection. I write versions here, because there are quite a few things different between spring versions.

    0 讨论(0)
提交回复
热议问题