博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring 接口代理 类代理
阅读量:6265 次
发布时间:2019-06-22

本文共 1092 字,大约阅读时间需要 3 分钟。

1.Question Description :

   when you use @Transactional annotation and @RequiresPermissions annotation (about shiro) together,

   you will find the @RequiresPermissions annotation donot work, why?

 

2. Explain:

    It's caused by the Proxy Mechanism of Spring, because the Spring framework preference for Interface Proxy than Class Proxy,

    the method of the class ExampleServiceImpl was agented several times.

    Let's look the two kinds of Interface.

    2.1 @Transactional Annotation:

          It was  based on the Interface Proxy default, so it will produce Proxy Object One just like ExampleServiceImpl$$;

   2.2  @RequiresPermissions :

         It was based on the Interface Proxy default too, but it produces Proxy Object Two based on Proxy Object One just like ExampleServiceImpl$$$$,

         that is a really Class Proxy.

  2.3  when the two kinds of Proxy way exist together,  the Classs Proxy will out of action.

 

3.  Solution:

          we should change its Proxy Way, as follows:

       

        and the same time, change the Proxy Way of Spring, as follows:

    

       then @RequiresPermissions Annotation works!

 

 

 

转载于:https://www.cnblogs.com/rocky-fang/p/5322724.html

你可能感兴趣的文章
用JS实现任意导航栏的调用
查看>>
【GDOI2018】所有题目和解题报告
查看>>
【BZOJ】3302: [Shoi2005]树的双中心 && 2103: Fire 消防站 && 2447: 消防站
查看>>
存储过程与触发器面试
查看>>
CSS系列:在HTML中引入CSS的方法
查看>>
Orcale约束-------檢查約束
查看>>
VS2013 配置CUDNN V4 DEMO
查看>>
Codeforces Round #207 (Div. 2)C. Knight Tournament
查看>>
JS(JavaScript)的进一步了解5(更新中···)
查看>>
python3基础学习笔记
查看>>
STL模板整理 pair
查看>>
【转】jmeter学习笔记——一个简单的性能测试
查看>>
企业级镜像管理系统Harbor
查看>>
A Plain English Guide to JavaScript Prototypes
查看>>
学习总结汇总
查看>>
Beta阶段测试报告
查看>>
JQ 练习题
查看>>
AndroidStudio、gradle、buildToolsVersion关系
查看>>
WPF入门教程系列八——布局之Grid与UniformGrid(三)
查看>>
递归调用顺序问题
查看>>