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!

Spring 接口代理 类代理的更多相关文章

  1. 如何获取hibernate代理类代理的实际对象实例?

    在hibernate中,通过sql语句查询带clob字段的记录,查出来的结果集是List<HashMap<String,Object>>类型,在调用jackson的接口转为js ...

  2. AOP 代理类的创建

    AOP 代理类的创建 入口:AnnotationAwareAspectJAutoProxyCreator#postProcessAfterInitialization 和 AnnotationAwar ...

  3. Spring学习之动态代理的简单实现

    先说一下代理模式的好处 1.可以使真实角色的操作更加纯粹,不用去关注一些公共的业务 2.公共的交给代理角色,实现了业务的分工 3.公共业务发生扩展的时候,方便集中管理 静态代理模式的缺点 1.一个真实 ...

  4. .net 代理类(WebService代理类的详解 )

    http://hi.baidu.com/654085966/item/53ee8c0f108ad78202ce1b1d   -----------转自 客户端调用Web Service的方式我现在知道 ...

  5. 啰里吧嗦式讲解java静态代理动态代理模式

    一.为啥写这个 文章写的比较啰嗦,有些东西可以不看,因为想看懂框架, 想了解SSH或者SSM框架的设计原理和设计思路, 又去重新看了一遍反射和注解, 然后看别人的博客说想要看懂框架得先看懂设计模式,于 ...

  6. Spring只定义接口自动代理接口实现类

    能够扫描到包 @ComponentScan("org.zxp.esclientrhl") ESCRegistrar类主要实现ImportBeanDefinitionRegistra ...

  7. 在spring中获取代理对象代理的目标对象工具类

    昨天晚上一哥们需要获取代理对象的目标对象,查找了文档发现没有相应的工具类,因此自己写了一个分享给大家.能获取JDK动态代理/CGLIB代理对象代理的目标对象. 问题描述:: 我现在遇到个棘手的问题,要 ...

  8. spring 依赖注入时,什么时候会创建代理类

    问题来源 以前一直有个疑惑,为什么我创建的controller中注入的service类有时候是代理类,有时候是普通javabean,当时能力不够,现在已经有了点经验就大胆跟了跟源码,看看到底咋回事. ...

  9. spring AbstractBeanDefinition创建bean类型是动态代理类的方式

    1.接口 Class<?> resourceClass 2.获取builder BeanDefinitionBuilder builder = BeanDefinitionBuilder. ...

随机推荐

  1. Mac mongodb 配置安装

    简单总结就几条,比较简单配置mongodb. 1,首先下载安装包:百度云下载地址 2,下载之后解压到自己常放的工作目录下,然后开始配置一下你的Mac环境 vim ~/.bash_profile 添加m ...

  2. OllyICE 调试的程序无法处理异常 解决方法

    问题描述 在用OllyICE打开可执行文件时出现如下图所示错误 解决方法 1. 选项 -> 调试设置 , 打开调试选项 2. 切换到 异常 页签 3. 取消勾选 忽略(传递给程序)以下异常: 单 ...

  3. VS2013 解决方案文件结构分析

    http://www.cnblogs.com/haogj/p/4248030.html Visual Studio 的解决方案文件是一个文本文件,其中的内容不是太复杂,有些时候 Visual Stud ...

  4. Linux设备驱动剖析之Input(三)

    /* get current state of buttons */ ; i < pdata->nbuttons; i++) gpio_keys_report_event(&dda ...

  5. Unity Remote 4安卓机使用指南

    必须U3D版本为4.5以上,可以在Public目录下载.想实时调试IOS版本必须是MAC系统! 优点:可以在不编译的情况下实时的去调试真实Android设备的各种情况,包括使用触摸功能(Remote接 ...

  6. jQuery的maskedinput插件 设置input掩码

    一.下载插件  http://digitalbush.com/projects/masked-input-plugin/二.属性a: 表示只能输入大小写字母9:表示只能输入0-9之间的数字*:a和9的 ...

  7. iOS-布局-Masonry-优先级

    一.AutoLayout有两个重要的属性: 1.Content Compression Resistance 百度翻译(内容压缩抗力) 2.Content Hugging    百度翻译(内容拥抱) ...

  8. 《HelloGitHub月刊》第01期

    <HelloGitHub月刊> 因为现在这个项目只有我自己做,只敢叫"月刊",希望有志同道合者,快点加入到这个项目中来!同时,如果您有更好的建议或者意见,欢迎联系我.联 ...

  9. python——第二天

    类和实例: 创建实例是通过类名+()实现 但是!可以自由地给每个实例变量绑定新的属性(特指以前在类定义中没有的属性) __init__方法用来给类定义必要的几个属性,第一个参数永远是self type ...

  10. 一个关于explain出来为all的说明及优化

    explain sql语句一个语句,得到如下结果,为什么已经创建了t_bill_invests.bid_id的索引,但却没有显示using index,而是显示all扫描方式呢,原来这还与select ...