配置Spring的任务调度时,使用了@Async注解用于异步调用,出了一个异常。
Exception:
Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
解决方法一:导入cglib-nodep-2.1_3.jar包,或者导入asm-2.2.3.jar和cglib-2.2.jar
解决方法二:为需要代理的目标类抽出接口。
这大概涉及到了String的AOP吧,没细琢磨,懂得人还请多多指教。
需要说明的一点:很多文章举例时把@Async和任务调度混在了一起,我自己试验了一下,发现任务调度和@Async没有必然联系,在xml配置中仅仅声明<task:annotation-driven/> 就可以使用@Async了。
觉得annotation真是很方便。
Exception:
Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
解决方法一:导入cglib-nodep-2.1_3.jar包,或者导入asm-2.2.3.jar和cglib-2.2.jar
解决方法二:为需要代理的目标类抽出接口。
这大概涉及到了String的AOP吧,没细琢磨,懂得人还请多多指教。
需要说明的一点:很多文章举例时把@Async和任务调度混在了一起,我自己试验了一下,发现任务调度和@Async没有必然联系,在xml配置中仅仅声明<task:annotation-driven/> 就可以使用@Async了。
觉得annotation真是很方便。