Spring 4.X 使用@AspectJ和Schema 报错
来源:互联网 发布:焊接模拟软件 编辑:程序博客网 时间:2024/06/07 12:18
**XML配置**
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <context:annotation-config/> <aop:aspectj-autoproxy proxy-target-class="true"/> <aop:config proxy-target-class="true"> <aop:aspect ref="mymethod"> <aop:before pointcut="target(main.com.Greeting) " method="Cutin"/> <aop:after pointcut="target(main.com.Greeting)" method="Cutin2"/> </aop:aspect> </aop:config> <bean id="mymethod" class="main.com.Cut"/> <bean id="mytest" class="main.com.Greeting"/>
xml配置如上,IntelliJ IDEA 报如下错误,找不到aspectj需要的类包。
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Around Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Around at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:225) at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:703) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at main.AopTest.main(AopTest.java:13) Caused by: java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Around at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.<clinit>(ReflectiveAspectJAdvisorFactory.java:77) at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.initBeanFactory(AnnotationAwareAspectJAutoProxyCreator.java:78) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.setBeanFactory(AbstractAdvisorAutoProxyCreator.java:60) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1647) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1615) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ... 11 more Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.annotation.Around at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
<aop:before pointcut="target(main.com.Greeting) " method="Cutin"/>
<aop:after pointcut="target(main.com.Greeting)" method="Cutin2"/>
<aop:aspectj-autoproxy proxy-target-class="true"/>
把上面的注释后不报错。但是无法生成AOP代理添加aspectj.weaver 和 aspectj.tools 类包的依赖后,错误消失,编译通过
阅读全文
1 0
- Spring 4.X 使用@AspectJ和Schema 报错
- 基于@AspectJ和Schema的AOP(精通Spring+4.x++企业应用开发实战 第八章)
- spring3.x第七章 基于@AspectJ和Schema的AOP
- 小曹学spring--基于@AspectJ和Schema的AOP
- Spring AOP的实现机制(三)---@AspectJ形式的Spring AOP和基于Schema的AOP
- 使用Spring AOP和AspectJ编排工作流
- AspectJ使用注解方式报错
- 关于spring切面使用<aop:aspectj-autoproxy/>报错的解决方法
- aspectj 使用spring AOP切面编程的时候报错:ReflectionWorld$ReflectionWorldException NoClassDefFoundError 的处理
- AOP框架之:Spring 2.x AOP和AspectJ
- Spring中Aspectj和Schema-based AOP混用引起的错误
- spring AspectJ基于注解报错问题以及基于xml后置通知和抛出异常通知报错问题
- 6.基于@AspectJ和Schema的AOP
- spring AspectJ 基本使用
- Spring-AOP 使用@AspectJ
- Spring mode = "aspectj" 配置事务报错
- Spring AOP 和 AspectJ
- Spring AOP 和 AspectJ
- 改进版python实现的归并排序
- DOM
- npm太慢, 淘宝npm镜像使用方法
- 什么是回程网络(backhual telecommunications )
- C++ -- 实现矩阵类
- Spring 4.X 使用@AspectJ和Schema 报错
- 【前端】js常用函数封装
- win32创建对话框的方法(1)
- Ubuntu下onos安装笔记
- SPSS Statistics(spss25.0)25.0中文免费版下载
- 学习笔记——12306 手动登录解析(1)
- 栈和队列
- 图形打印
- 4个我经常滥用的unix命令