我要将spring facebook登录与hibernate集成。我已经实现了以下配置但尚未使用。
当我点击使用facebook按钮登录时,它会被重定向到facebook登录页面,但是当我点击登录按钮时,我收到以下错误:
HTTP Status 500 - org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select userId from UserConnection where providerId = ? and providerUserId = ?]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.userconnection' doesn't exist
我的xml配置如下: -
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="url" value="${url}" />
<property name="username" value="${user}" />
<property name="password" value="${password}" />
<property name="driverClassName" value="${driver}" />
<!-- <property name="maxActive" value="${pool.max_active}" />
<property name="maxIdle" value="${pool.max_idle}" />
<property name="maxWait" value="${pool.max_wait}" />
<property name="defaultAutoCommit" value="false" /> -->
</bean>
<bean id="customLogoutSuccessHandler" class="com.security.core.filter.CustomLogoutSuccessHandler"></bean>
<bean id="customAuthenticationSuccessHandler" class="com.security.core.filter.CustomAuthenticationSuccessHandler"></bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" destroy-method="destroy">
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value=" />
<!-- <property name="annotatedClasses">
<list>
<value></value>
<value></value>
</list>
</property> -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl}</prop>
<prop key="hibernate.id.new_generator_mappings">true</prop>
<prop key="connection.pool_size">1</prop>
<prop key="hibernate.c3p0.debugUnreturnedConnectionStackTraces">true</prop>
<prop key="hibernate.c3p0.unreturnedConnectionTimeout">60</prop>
<!-- <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
<prop key="hibernate.current_session_context_class">managed</prop> -->
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<context:component-scan base-package="com.nuts2invest" />
<tx:annotation-driven transaction-manager="transactionManager" />
<context:annotation-config />
<aop:aspectj-autoproxy />
<bean id="dbHelper" class="com.server.db.dao.HibernateUtil">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- ================= Facebook Configuration ============== -->
<!-- This is used to hash the password of the user. -->
<bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder">
<constructor-arg index="0" value="10"/>
</bean>
<!--
Configures the social authentication filter which integrates Spring Social
with Spring Security.
-->
<bean id="socialAuthenticationFilter" class="org.springframework.social.security.SocialAuthenticationFilter">
<constructor-arg index="0" ref="authenticationManager"/>
<constructor-arg index="1" ref="userIdSource"/>
<constructor-arg index="2" ref="usersConnectionRepository"/>
<constructor-arg index="3" ref="connectionFactoryLocator"/>
<!-- Sets the url of the registration form. -->
<property name="signupUrl" value="/onRegisterClick"/>
</bean>
<!-- <bean id="locator" class="org.springframework.social.connect.ConnectionFactory"></bean> -->
<!--
Configures the social authentication provider which processes authentication requests
made by using supported social authentication services (FB, Twitter and so on).
-->
<bean id="socialAuthenticationProvider" class="org.springframework.social.security.SocialAuthenticationProvider">
<constructor-arg index="0" ref="usersConnectionRepository"/>
<constructor-arg index="1" ref="socialUserDetailsService"/>
</bean>
<!--
This bean is used to load the user specific data when social sign in
is used.
-->
<bean id="socialUserDetailsService" class="com.nuts2invest.security.SimpleSocialUserDetailsService">
<!-- <constructor-arg index="0" ref="userDetailsService"/>
--> </bean>
<!--
This bean determines the account ID of the user. The example application
uses the username as the account ID.
-->
<bean id="userIdSource" class="org.springframework.social.security.AuthenticationNameUserIdSource"/>
<bean id="connectionFactoryLocator" class="org.springframework.social.security.SocialAuthenticationServiceRegistry">
<property name="authenticationServices">
<list>
<bean class="org.springframework.social.facebook.security.FacebookAuthenticationService">
<constructor-arg value="rer4343434"/>
<constructor-arg value="43434rererererer3434" />
</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.JdbcUsersConnectionRepository">
<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>
<!-- <facebook:config app-id="xxxyyyzzz" app-secret="zzzyyyxxx"/> -->
<!-- <social:jdbc-connection-repository/> -->
<bean class="org.springframework.social.connect.web.ConnectController">
<constructor-arg value="http://localhost:8080/war" />
<!-- relies on by-type autowiring for the other constructor-args -->
</bean>