current position:Home>Springboot uses aopcontext Currentproxy() keeps reporting cannot find current proxy: set 'exposeproxy' property on

Springboot uses aopcontext Currentproxy() keeps reporting cannot find current proxy: set 'exposeproxy' property on

2022-01-26 22:40:46 CSDN Q & A

SpringUtils Tool class

    @SuppressWarnings("unchecked")    public static <T> T getAopProxy(T invoker)    {        return (T) AopContext.currentProxy();    }

call getAopProxy Method

    @Override    public List<SysRole> selectRoleAll() {        return SpringUtils.getAopProxy(this).selectRoleList(new SysRole());    }

@EnableAspectJAutoProxy(exposeProxy = true,proxyTargetClass = true) Already added , call selectRoleAll Method
Has been an error Cannot find current proxy: Set 'exposeProxy' property on Advised to 'true' to make it available, and ensure that AopContext.currentProxy() is invoked in the same thread as the AOP invocation context.] with root cause




Refer to the answer 1:

img


true You can get the agent

img


cglib Agents have the same processing logic




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201262240451378.html

Random recommended