Spring Social-无法生成CGLIB子类

 武艺最新单曲问月09 发布于 2023-02-07 17:34

尝试导航到spring社交Web模块的/ 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的相关部分:


    contextConfigLocation
    
        /WEB-INF/appContext.xml
    



    org.springframework.web.context.ContextLoaderListener



    mvc-dispatcher
    org.springframework.web.servlet.DispatcherServlet
    
        contextConfigLocation
        
    
    1

appContext.xml的相关部分:


        
            
                
                    
                                    
                
            
        
    

    
        
        
        
    

    
        
        
    

感谢您的任何答复。

1 个回答
  • 我发现此链接很有用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>
    

    希望这会有所帮助。快乐的编码:)

    2023-02-07 17:37 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有