exposeProxy = true not in effect
See original GitHub issueSorry, my English is not very good.
describe:
I use @EnableAspectJAutoProxy(exposeProxy = true),but I can not get the current AOP proxy by AopContex.currentProxy().
environment: Spring Boot (2.1.4.RELEASE).
There are only two classes of this project:
@SpringBootApplication
@EnableAsync
@EnableAspectJAutoProxy(exposeProxy = true)
public class DemoTest2Application {
public static void main(String[] args) {
SpringApplication.run(DemoTest2Application.class, args);
}
}
@Controller
public class EmailController {
@RequestMapping(value = "/test", method = RequestMethod.GET)
@ResponseBody
public Object asyncCall() throws InterruptedException {
System.out.println("before....");
((EmailController) AopContext.currentProxy()).testAsyncTask();
System.out.println("after....");
return "OK";
}
@Async
public void testAsyncTask() throws InterruptedException {
Thread.sleep(10000);
System.out.println("异步任务执行完成!");
}
}
when I request “localhost:8080/test” .I get exception:
java.lang.IllegalStateException: Cannot find current proxy: Set 'exposeProxy' property on Advised to 'true' to make it available.
at org.springframework.aop.framework.AopContext.currentProxy(AopContext.java:69) ~[spring-aop-5.1.6.RELEASE.jar:5.1.6.RELEASE]
Looking through all kinds of documents, I don’t know where I was wrong.
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (5 by maintainers)
Top Results From Across the Web
Using proxy-target-class="true" with Spring beans
This behavior is not exhibited when using JDK proxies. ... are usually only assignments taking place and no real logic is implemented in...
Read more >9.5 Using the ProxyFactoryBean to create AOP proxies - Spring
exposeProxy : determines whether or not the current proxy should be exposed in ... property is set to true will cause CGLIB-based proxying...
Read more >6 Spring Transaction Failure Scenarios that Everyone Has ...
Use the real class instead of the proxy class when doInsert() calling, so the transaction will fail. The solution can be to directly...
Read more >cannot find current proxy: set 'exposeproxy' property on advised to ...
测试前请确保开启了(exposeProxy = true),此参数暴露代理对象,否则AopContext. ... The bean could not be injected as a because it is a JDK dynamic proxy that ...
Read more >Chapter 12. Aspect Oriented Programming with Spring.NET
NET IoC container does not depend on AOP, meaning you don't need to use AOP if you ... If a target needs to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this works for me, set the property manually