我是Spring社交新手,嘗試爲LinkedIn配置spring社交登錄。Spring Social Linkedin - 登錄
低於我的Spring配置文件,
<context:component-scan base-package="com.tc.web">
<context:include-filter type="regex"
expression="(service|controller|component)\..*" />
</context:component-scan>
<bean id="connectionFactoryLocator"
class="org.springframework.social.connect.support. ConnectionFactoryRegistry">
<property name="connectionFactories">
<list>
<bean
class="org.springframework.social.linkedin.connect .LinkedInConnectionFactory">
<constructor-arg value="key........" />
<constructor-arg value="secret .........." />
</bean>
</list>
</property>
</bean>
<bean id="textEncryptor" class="org.springframework.security.crypto.encrypt .Encryptors"
factory-method="noOpText" />
<bean id="usersConnectionRepository"
class="org.springframework.social.connect.jdbc.Jdb cUsersConnectionRepository">
<constructor-arg ref="dataSource" />
<constructor-arg ref="connectionFactoryLocator" />
<constructor-arg ref="textEncryptor" />
</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.tc.web.social.signin.SocialSignInAdapte r" />
<bean class="org.springframework.social.connect.web.Prov iderSignInController">
<!-- relies on by-type autowiring for the constructor-args -->
<constructor-arg ref="signInAdapter" />
<property name="applicationUrl" value="link" />
<property name="signUpUrl" value="link" />
<property name="signInUrl" value="link" />
</bean>
我SocialSignInAdapter.java是,
公共類SocialSignInAdapter實現SignInAdapter {
@Override
public String signIn(String userId, Connection<?> connection, NativeWebRequest request) {
System.out.println("User Id is ===>>> "+userId);
System.out.println("Connection is ====>>> "+connection);
return null;
}
}
login.jsp中,
<li class="linkedin"><a href="${pageContext.request.contextPath}/signin/linkedin" title="LinkedIn"> </a></li>
當我點擊上面的linkedin鏈接時,我得到404錯誤。
我想我的應用程序無法找到該請求的ProviderSignInController:// dom:8080/myApp/signin/linkedin。
我懷疑spring xml中的下面的配置。
<context:component-scan base-package="com.tc.web">
<context:include-filter type="regex"
expression="(service|controller|component)\..*" />
</context:component-scan>
我把所有的控制器放在com.tc.web包裏面。但ProviderSignInController在Spring包中,我的應用程序無法找到它。
我也試過以下。
<context:component-scan base-package="com.tc.web,org.springframework.social.con nect.web">
<context:include-filter type="regex"
expression="(service|controller|component)\..*" />
</context:component-scan>
我得到了具有上述配置的ProviderSignInController的ambigous映射錯誤。 所以,我從我的Spring XML刪除
<bean class="org.springframework.social.connect.web.Prov iderSignInController">
<!-- relies on by-type autowiring for the constructor-args -->
<constructor-arg ref="signInAdapter" />
<property name="applicationUrl" value="link" />
<property name="signUpUrl" value="link" />
<property name="signInUrl" value="link" />
</bean>
。但仍然收到404錯誤。
任何人都可以幫助我在此請..........
感謝, Baskar.S