java – Spring Social – 无法生成CGLIB子类
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – Spring Social – 无法生成CGLIB子类,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3292字,纯文字阅读大概需要5分钟。
内容图文
![java – Spring Social – 无法生成CGLIB子类](/upload/InfoBanner/zyjiaocheng/804/4a5299cb649341278929772c7908d346.jpg)
尝试导航到spring社交网络模块的/ connect端点时,我收到以下错误.
我得到了什么:
[Request processing failed; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'scopedTarget.connectionRepository'
defined in ServletContext resource [/WEB-INF/appContext.xml]:
Initialization of bean failed; nested exception is
org.springframework.aop.framework.AopConfigException:
Could not generate CGLIB subclass of class
[class org.springframework.social.connect.jdbc.JdbcConnectionRepository]:
Common causes of this problem include using a final class or a non-visible class;
nested exception is java.lang.IllegalArgumentException:
Superclass has no null constructors but no arguments were given]
web.xml的相关部分:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/appContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
appContext.xml的相关部分:
<bean id="connectionFactoryLocator"
class="org.springframework.social.connect.support.ConnectionFactoryRegistry">
<property name="connectionFactories">
<list>
<bean class="org.springframework.social.facebook.connect.FacebookConnectionFactory">
<constructor-arg value="${facebook.clientId}" />
<constructor-arg value="${facebook.clientSecret}" />
</bean>
</list>
</property>
</bean>
<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>
感谢您的回复.
解决方法:
我觉得这个链接很有用https://github.com/socialsignin/socialsignin-showcase/issues/6,它解决了我的问题.
基本上在这种情况下问题是AOP代理,由于某种原因CGLIB代理在这种情况下不起作用.所以你必须将其关闭并切换到JDK代理.所以我所做的只是在我的context.xml中进行此更改 –
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true"/>
至
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="false"/>
通过使proxy-target-class =“false”spring将使用JDK代理(不要问为什么我不知道).
它解决了我的问题.
但如果它不适合你,那么也改变这个:
<security:global-method-security proxy-target-class="false" >
还有这个:
<bean id="connectionFactoryLocator" class="org.springframework.social.connect.support.ConnectionFactoryRegistry">
<property name="connectionFactories">
<list>
<bean class="org.springframework.social.facebook.connect.FacebookConnectionFactory">
<constructor-arg value="xxxxxxxxxxx" />
<constructor-arg value="xxxxxxxxxxxxxxxxxxxxxxxxxxx" />
</bean>
</list>
</property>
<aop:scoped-proxy proxy-target-class="false"/>
</bean>
希望这有帮助.快乐编码:)
内容总结
以上是互联网集市为您收集整理的java – Spring Social – 无法生成CGLIB子类全部内容,希望文章能够帮你解决java – Spring Social – 无法生成CGLIB子类所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。