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:

        Spring 接口代理 类代理

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

    Spring 接口代理 类代理

       then @RequiresPermissions Annotation works!

 

 

 

相关文章:

  • 2022-12-23
  • 2021-05-31
  • 2021-09-08
  • 2021-06-04
  • 2021-08-02
  • 2021-07-17
  • 2021-05-31
  • 2021-05-27
猜你喜欢
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
  • 2021-09-02
  • 2021-09-15
  • 2021-12-16
  • 2022-01-07
相关资源
相似解决方案