zoukankan      html  css  js  c++  java
  • Spring 接口代理 类代理

    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!

     

  • 相关阅读:
    011-通过网络协议解析网络请求-DNS-ARP-TCPIP
    010-HTTP协议
    009-DNS域名解析系统
    008-ICMP协议(网络控制文协议)
    007-IP报文协议
    007-排序算法-堆排序
    006-排序算法-希尔排序
    007-Linux 查看端口
    005-排序算法-归并排序
    004-排序算法-选择排序
  • 原文地址:https://www.cnblogs.com/rocky-fang/p/5322724.html
Copyright © 2011-2022 走看看