2012-04-27 98 views
1

我已經閱讀了spring社交文檔,但配置的一部分是基於Java的,但我的項目配置是基於xml的。所以請告訴我在spring xml配置文件中spring spring是如何配置的。謝謝你,對不起我的可憐的英語spring社交xml配置

+1

請提供這基於代碼的配置,或者在最少,鏈接到它。或者甚至更好:閱讀關於基於代碼的配置的文檔(http://static.springsource.org/spring-framework/docs/current/spring-framework-reference/html/beans.html#beans-java)以及他自己的port例子。 – 2012-04-27 06:39:23

+0

@Sejuju - 在你的問題上多加點努力會產生更好的迴應。你閱讀文檔,這是一個好的開始。現在展示你的嘗試,你一定會得到很好的迴應。 – Marijn 2012-04-27 07:40:26

回答

0

你必須創建一個社交配置xml文件,你必須導入到您的root-context.xml文件中。此外,您可能會考慮使用spring安全性來配置您的應用程序。這取決於你的項目架構。

樣品春天社會的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> 

樣品根的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"/>