`
jinnianshilongnian
  • 浏览: 21504356 次
  • 性别: Icon_minigender_1
博客专栏
5c8dac6a-21dc-3466-8abb-057664ab39c7
跟我学spring3
浏览量:2418719
D659df3e-4ad7-3b12-8b9a-1e94abd75ac3
Spring杂谈
浏览量:3008853
43989fe4-8b6b-3109-aaec-379d27dd4090
跟开涛学SpringMVC...
浏览量:5639520
1df97887-a9e1-3328-b6da-091f51f886a1
Servlet3.1规范翻...
浏览量:259943
4f347843-a078-36c1-977f-797c7fc123fc
springmvc杂谈
浏览量:1597359
22722232-95c1-34f2-b8e1-d059493d3d98
hibernate杂谈
浏览量:250234
45b32b6f-7468-3077-be40-00a5853c9a48
跟我学Shiro
浏览量:5858981
Group-logo
跟我学Nginx+Lua开...
浏览量:702015
5041f67a-12b2-30ba-814d-b55f466529d5
亿级流量网站架构核心技术
浏览量:785234
社区版块
存档分类
最新评论

【第六章】 AOP 之 6.2 AOP的HelloWorld ——跟我学spring3

阅读更多

 

6.2.1  准备环境

       首先准备开发需要的jar包,请到spring-framework-3.0.5.RELEASE-dependencies.zip和spring-framework-3.0.5.RELEASE-with-docs中查找如下jar包:

 
 

org.springframework.aop-3.0.5.RELEASE.jar

com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar

com.springsource.org.aopalliance-1.0.0.jar

com.springsource.net.sf.cglib-2.2.0.jar

 

 

 

 

 

 

 

 

 

将这些jar包添加到“Build Path”下。

 

6.2.2  定义目标类

       1)定义目标接口:

 

java代码:
  1. package cn.javass.spring.chapter6.service;  
  2. public interface IHelloWorldService {  
  3.     public void sayHello();  
  4. }  

 

       2)定义目标接口实现:

 

java代码:
  1. package cn.javass.spring.chapter6.service.impl;  
  2. import cn.javass.spring.chapter6.service.IHelloWorldService;  
  3. public class HelloWorldService implements IHelloWorldService {  
  4.     @Override  
  5.     public void sayHello() {  
  6.         System.out.println("============Hello World!");  
  7.     }  
  8. }  
  9.    

 

       注:在日常开发中最后将业务逻辑定义在一个专门的service包下,而实现定义在service包下的impl包中,服务接口以IXXXService形式,而服务实现就是XXXService,这就是规约设计,见名知义。当然可以使用公司内部更好的形式,只要大家都好理解就可以了。

 

6.2.2  定义切面支持类

       有了目标类,该定义切面了,切面就是通知和切入点的组合,而切面是通过配置方式定义的,因此这定义切面前,我们需要定义切面支持类,切面支持类提供了通知实现:

 

java代码:
  1. package cn.javass.spring.chapter6.aop;  
  2. public class HelloWorldAspect {  
  3.        //前置通知  
  4.     public void beforeAdvice() {  
  5.         System.out.println("===========before advice");  
  6. }  
  7. //后置最终通知  
  8.     public void afterFinallyAdvice() {  
  9.         System.out.println("===========after finally advice");  
  10.     }  
  11. }  

 

       此处HelloWorldAspect类不是真正的切面实现,只是定义了通知实现的类,在此我们可以把它看作就是缺少了切入点的切面。

 

       注:对于AOP相关类最后专门放到一个包下,如“aop”包,因为AOP是动态织入的,所以如果某个目标类被AOP拦截了并应用了通知,可能很难发现这个通知实现在哪个包里,因此推荐使用规约命名,方便以后维护人员查找相应的AOP实现。

 

6.2.3  在XML中进行配置

       有了通知实现,那就让我们来配置切面吧:

       1)首先配置AOP需要aop命名空间,配置头如下:

 

java代码:
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans  xmlns="http://www.springframework.org/schema/beans"  
  3.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.         xmlns:aop="http://www.springframework.org/schema/aop"  
  5.         xsi:schemaLocation="  
  6.            http://www.springframework.org/schema/beans  
  7.            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
  8.            http://www.springframework.org/schema/aop  
  9.            http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">  
  10. </beans>  
  11.    

 

 

       2)配置目标类:

 

java代码:
  1. <bean id="helloWorldService"  
  2. class="cn.javass.spring.chapter6.service.impl.HelloWorldService"/>  
  3.    

 

       3)配置切面:

 

java代码:
  1. <bean id="aspect" class="cn.javass.spring.chapter6.aop.HelloWorldAspect"/>  
  2. <aop:config>  
  3. <aop:pointcut id="pointcut" expression="execution(* cn.javass..*.*(..))"/>  
  4.     <aop:aspect ref="aspect">  
  5.         <aop:before pointcut-ref="pointcut" method="beforeAdvice"/>  
  6.         <aop:after pointcut="execution(* cn.javass..*.*(..))" method="afterFinallyAdvice"/>  
  7.     </aop:aspect>  
  8. </aop:config>  

 

       切入点使用<aop:config>标签下的<aop:pointcut>配置,expression属性用于定义切入点模式,默认是AspectJ语法,“execution(* cn.javass..*.*(..))”表示匹配cn.javass包及子包下的任何方法执行。

 

切面使用<aop:config>标签下的<aop:aspect>标签配置,其中“ref”用来引用切面支持类的方法。

 

前置通知使用<aop:aspect>标签下的<aop:before>标签来定义,pointcut-ref属性用于引用切入点Bean,而method用来引用切面通知实现类中的方法,该方法就是通知实现,即在目标类方法执行之前调用的方法。

 

最终通知使用<aop:aspect>标签下的<aop:after >标签来定义,切入点除了使用pointcut-ref属性来引用已经存在的切入点,也可以使用pointcut属性来定义,如pointcut="execution(* cn.javass..*.*(..))",method属性同样是指定通知实现,即在目标类方法执行之后调用的方法。

 

6.2.4    运行测试

测试类非常简单,调用被代理Bean跟调用普通Bean完全一样,Spring AOP将为目标对象创建AOP代理,具体测试代码如下:

 

java代码:
  1. package cn.javass.spring.chapter6;  
  2. import org.junit.Test;  
  3. import org.springframework.context.ApplicationContext;  
  4. import org.springframework.context.support.ClassPathXmlApplicationContext;  
  5. import cn.javass.spring.chapter6.service.IHelloWorldService;  
  6. import cn.javass.spring.chapter6.service.IPayService;  
  7. public class AopTest {  
  8.     @Test  
  9.     public void testHelloworld() {  
  10.         ApplicationContext ctx =  new ClassPathXmlApplicationContext("chapter6/helloworld.xml");  
  11.         IHelloWorldService helloworldService =  
  12.         ctx.getBean("helloWorldService", IHelloWorldService.class);  
  13.         helloworldService.sayHello();  
  14.     }  
  15. }  
  16.    

 

       该测试将输出如下如下内容:

 

java代码:
  1. ===========before advice  
  2. ============Hello World!  
  3. ===========after finally advice  

 

 

       从输出我们可以看出:前置通知在切入点选择的连接点(方法)之前允许,而后置通知将在连接点(方法)之后执行,具体生成AOP代理及执行过程如图6-4所示。

 

图6-4 Spring AOP框架生成AOP代理过程

 

 

原创内容 转自请注明出处【http://sishuok.com/forum/blogPost/list/2467.html


 

分享到:
评论
42 楼 DEAR贴 2017-07-21  
切面植入的时机是什么呢
41 楼 yang408485700 2016-08-11  
Cool1 写道
jinnianshilongnian 写道
zhuguopei_java 写道

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloWorldService' defined in class path resource [helloworld.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.aspectj.AspectJMethodBeforeAdvice] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.config.MethodLocatingFactoryBean] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [spring.aop.HelloWorldAspect] for bean with name 'aspect' defined in class path resource [helloworld.xml]; nested exception is java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [spring.aop.HelloWorldAspect] for bean with name 'aspect' defined in class path resource [helloworld.xml]; nested exception is java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect
找了N长时间了,就是解决不了  


没有导入后三个包。



java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect

你仔细检查下这个类路径写没写错; 有木有在classpath下,

这个好像和版本有一定的问题,我在4.0的版本下也是出现这个问题,然后换成了3.1之后就没问题了。

40 楼 hx252502115 2016-08-09  
浮生还闲了半天 写道
<aop:before pointcut-ref="pointcut" method="beforeAdvice"/> 
        <aop:before pointcut-ref="pointcut" method="beforeAdvice"/>
        <aop:after pointcut="execution(* cn.javass..*.*(..))" method="afterFinallyAdvice"/> 
老师 这样写的话结果是
===========before advice
============Hello World!
===========before advice
===========after finally advice
还是有一条在后面
  <aop:before pointcut-ref="pointcut" method="beforeAdvice"/> 
      
        <aop:after pointcut="execution(* cn.javass..*.*(..))" method="afterFinallyAdvice"/>
结果是:
============Hello World!
===========before advice
===========after finally advice
这是因为 hello world!运行太快的原因吗


贴出完整的配置看看,这个和hello world运行快慢没有关系
39 楼 浮生还闲了半天 2016-05-03  
<aop:before pointcut-ref="pointcut" method="beforeAdvice"/> 
        <aop:before pointcut-ref="pointcut" method="beforeAdvice"/>
        <aop:after pointcut="execution(* cn.javass..*.*(..))" method="afterFinallyAdvice"/> 
老师 这样写的话结果是
===========before advice
============Hello World!
===========before advice
===========after finally advice
还是有一条在后面
  <aop:before pointcut-ref="pointcut" method="beforeAdvice"/> 
      
        <aop:after pointcut="execution(* cn.javass..*.*(..))" method="afterFinallyAdvice"/>
结果是:
============Hello World!
===========before advice
===========after finally advice
这是因为 hello world!运行太快的原因吗
38 楼 浮生还闲了半天 2016-05-03  
============Hello World!
===========before advice
===========after finally advice
老师我的输出结果是这样的 before advice没有前置  xml对了好几遍了
37 楼 youyao816 2016-03-07  
本兮挚爱桃子 写道
配置。。。。。
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans       
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context               
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop       
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<bean id="telSender" class="com.ccitsoft.Interface.TelSender" />

<bean id="aspect" class="com.ccitsoft.Interface.AspectSender">
<aop:config>
<aop:pointcut id="pointcut" expression="execution(* com.ccitsoft.Interface.*.*(..))" />

<aop:aspect ref="aspect">
<aop:before pointcut-ref="pointcut" method="beforeAdvice" />
<aop:after pointcut-ref="pointcut" method="afterAdvice" />
</aop:aspect>
</aop:config>


</bean>

</beans> 


测试类。。。。。
package com.ccitsoft.test;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ccitsoft.Interface.TelSender;

public class TestAspect {

@Test
public void test() {

ApplicationContext cxt = new ClassPathXmlApplicationContext("aspectSender.xml");

TelSender sender = cxt.getBean("telSender", TelSender.class);


sender.sender();

}

}
异常。。。。。。。。。
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionDecorator for element [config]
Offending resource: class path resource [aspectSender.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.fatal(FailFastProblemReporter.java:59)
at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:55)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.findDecoratorForNode(NamespaceHandlerSupport.java:119)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.decorate(NamespaceHandlerSupport.java:97)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.decorateIfRequired(BeanDefinitionParserDelegate.java:1372)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.decorateBeanDefinitionIfRequired(BeanDefinitionParserDelegate.java:1359)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.decorateBeanDefinitionIfRequired(BeanDefinitionParserDelegate.java:1339)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.processBeanDefinition(DefaultBeanDefinitionDocumentReader.java:261)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:154)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.ccitsoft.test.TestAspect.test(TestAspect.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

老师。有时间帮忙看下、貌似是哪个表达式有问题?
aop:config 不要写在bean里面
36 楼 youyao816 2016-03-07  
本兮挚爱桃子 写道
配置。。。。。
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans       
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context               
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop       
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<bean id="telSender" class="com.ccitsoft.Interface.TelSender" />

<bean id="aspect" class="com.ccitsoft.Interface.AspectSender">
<aop:config>
<aop:pointcut id="pointcut" expression="execution(* com.ccitsoft.Interface.*.*(..))" />

<aop:aspect ref="aspect">
<aop:before pointcut-ref="pointcut" method="beforeAdvice" />
<aop:after pointcut-ref="pointcut" method="afterAdvice" />
</aop:aspect>
</aop:config>


</bean>

</beans> 


测试类。。。。。
package com.ccitsoft.test;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ccitsoft.Interface.TelSender;

public class TestAspect {

@Test
public void test() {

ApplicationContext cxt = new ClassPathXmlApplicationContext("aspectSender.xml");

TelSender sender = cxt.getBean("telSender", TelSender.class);


sender.sender();

}

}
异常。。。。。。。。。
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionDecorator for element [config]
Offending resource: class path resource [aspectSender.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.fatal(FailFastProblemReporter.java:59)
at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:55)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.findDecoratorForNode(NamespaceHandlerSupport.java:119)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.decorate(NamespaceHandlerSupport.java:97)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.decorateIfRequired(BeanDefinitionParserDelegate.java:1372)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.decorateBeanDefinitionIfRequired(BeanDefinitionParserDelegate.java:1359)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.decorateBeanDefinitionIfRequired(BeanDefinitionParserDelegate.java:1339)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.processBeanDefinition(DefaultBeanDefinitionDocumentReader.java:261)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:154)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.ccitsoft.test.TestAspect.test(TestAspect.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

老师。有时间帮忙看下、貌似是哪个表达式有问题?
我也遇到了  怎么解决的?
35 楼 Cool1 2015-05-04  
jinnianshilongnian 写道
zhuguopei_java 写道

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloWorldService' defined in class path resource [helloworld.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.aspectj.AspectJMethodBeforeAdvice] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.config.MethodLocatingFactoryBean] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [spring.aop.HelloWorldAspect] for bean with name 'aspect' defined in class path resource [helloworld.xml]; nested exception is java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [spring.aop.HelloWorldAspect] for bean with name 'aspect' defined in class path resource [helloworld.xml]; nested exception is java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect
找了N长时间了,就是解决不了  




java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect

你仔细检查下这个类路径写没写错; 有木有在classpath下,

这个好像和版本有一定的问题,我在4.0的版本下也是出现这个问题,然后换成了3.1之后就没问题了。
34 楼 本兮挚爱桃子 2014-04-28  
配置。。。。。
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans       
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context               
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop       
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<bean id="telSender" class="com.ccitsoft.Interface.TelSender" />

<bean id="aspect" class="com.ccitsoft.Interface.AspectSender">
<aop:config>
<aop:pointcut id="pointcut" expression="execution(* com.ccitsoft.Interface.*.*(..))" />

<aop:aspect ref="aspect">
<aop:before pointcut-ref="pointcut" method="beforeAdvice" />
<aop:after pointcut-ref="pointcut" method="afterAdvice" />
</aop:aspect>
</aop:config>


</bean>

</beans> 


测试类。。。。。
package com.ccitsoft.test;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ccitsoft.Interface.TelSender;

public class TestAspect {

@Test
public void test() {

ApplicationContext cxt = new ClassPathXmlApplicationContext("aspectSender.xml");

TelSender sender = cxt.getBean("telSender", TelSender.class);


sender.sender();

}

}
异常。。。。。。。。。
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionDecorator for element [config]
Offending resource: class path resource [aspectSender.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.fatal(FailFastProblemReporter.java:59)
at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:55)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.findDecoratorForNode(NamespaceHandlerSupport.java:119)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.decorate(NamespaceHandlerSupport.java:97)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.decorateIfRequired(BeanDefinitionParserDelegate.java:1372)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.decorateBeanDefinitionIfRequired(BeanDefinitionParserDelegate.java:1359)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.decorateBeanDefinitionIfRequired(BeanDefinitionParserDelegate.java:1339)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.processBeanDefinition(DefaultBeanDefinitionDocumentReader.java:261)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:154)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.ccitsoft.test.TestAspect.test(TestAspect.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

老师。有时间帮忙看下、貌似是哪个表达式有问题?
33 楼 jinnianshilongnian 2013-10-09  
lovme_forever 写道
1、如果这样加载xml文件的话,
Resource rc = new FileSystemResource(new File("src/aop/aop.xml"));
@SuppressWarnings("deprecation")
BeanFactory ctx = new XmlBeanFactory(rc);
HelloWoldService hello = (HelloWoldService) ctx.getBean("helloWorldService");
hello.sayHello();


输出结果
============Hello World!

2、如果下面这种,输出就会正常
ApplicationContext ctx = new ClassPathXmlApplicationContext("file:src/aop/aop.xml");
HelloWoldService hello = (HelloWoldService) ctx.getBean("helloWorldService");
hello.sayHello();

输出结果
===========before advice
============Hello World!
===========after finally advice

BeanFactory没有如aop、消息、资源加载、事件等功能
32 楼 lovme_forever 2013-10-08  
1、如果这样加载xml文件的话,
Resource rc = new FileSystemResource(new File("src/aop/aop.xml"));
@SuppressWarnings("deprecation")
BeanFactory ctx = new XmlBeanFactory(rc);
HelloWoldService hello = (HelloWoldService) ctx.getBean("helloWorldService");
hello.sayHello();


输出结果
============Hello World!

2、如果下面这种,输出就会正常
ApplicationContext ctx = new ClassPathXmlApplicationContext("file:src/aop/aop.xml");
HelloWoldService hello = (HelloWoldService) ctx.getBean("helloWorldService");
hello.sayHello();

输出结果
===========before advice
============Hello World!
===========after finally advice
31 楼 zhuguopei_java 2013-06-26  
jinnianshilongnian 写道
那就是classpath下没有那个类  你可以使用Class.forName 测试下 

tao哥,可以了,,,刚刚我改错地方了。   
30 楼 jinnianshilongnian 2013-06-26  
那就是classpath下没有那个类  你可以使用Class.forName 测试下 
29 楼 zhuguopei_java 2013-06-26  
jinnianshilongnian 写道
zhuguopei_java 写道

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloWorldService' defined in class path resource [helloworld.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.aspectj.AspectJMethodBeforeAdvice] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.config.MethodLocatingFactoryBean] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [spring.aop.HelloWorldAspect] for bean with name 'aspect' defined in class path resource [helloworld.xml]; nested exception is java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [spring.aop.HelloWorldAspect] for bean with name 'aspect' defined in class path resource [helloworld.xml]; nested exception is java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect
找了N长时间了,就是解决不了  




java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect

你仔细检查下这个类路径写没写错; 有木有在classpath下,


还是不行,,,,
28 楼 jinnianshilongnian 2013-06-26  
zhuguopei_java 写道

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloWorldService' defined in class path resource [helloworld.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.aspectj.AspectJMethodBeforeAdvice] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.config.MethodLocatingFactoryBean] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [spring.aop.HelloWorldAspect] for bean with name 'aspect' defined in class path resource [helloworld.xml]; nested exception is java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [spring.aop.HelloWorldAspect] for bean with name 'aspect' defined in class path resource [helloworld.xml]; nested exception is java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect
找了N长时间了,就是解决不了  




java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect

你仔细检查下这个类路径写没写错; 有木有在classpath下,
27 楼 zhuguopei_java 2013-06-26  

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloWorldService' defined in class path resource [helloworld.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.aspectj.AspectJMethodBeforeAdvice] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.config.MethodLocatingFactoryBean] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [spring.aop.HelloWorldAspect] for bean with name 'aspect' defined in class path resource [helloworld.xml]; nested exception is java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [spring.aop.HelloWorldAspect] for bean with name 'aspect' defined in class path resource [helloworld.xml]; nested exception is java.lang.ClassNotFoundException: spring.aop.HelloWorldAspect
找了N长时间了,就是解决不了  
26 楼 jinnianshilongnian 2013-06-23  
jzzwy 写道
sorriest-siben 写道
<aop:pointcut id="pointcut" expression="execution(* cn.javass..*.*(..))"/>
请问* cn.javass..*.*(..)这里,第一个星号和cn之间要空格,为什么呢?

这个问题和 int add(){} 方法 int和add之间如果没有空格还脚方法么 ,
表达式的第一个*代表任意有无返回值的方法

语法规则, 第一个* 代表任意返回值 如果不加空格 就无法和包名区分了
25 楼 jzzwy 2013-06-23  
sorriest-siben 写道
<aop:pointcut id="pointcut" expression="execution(* cn.javass..*.*(..))"/>
请问* cn.javass..*.*(..)这里,第一个星号和cn之间要空格,为什么呢?

这个问题和 int add(){} 方法 int和add之间如果没有空格还脚方法么 ,
表达式的第一个*代表任意有无返回值的方法
24 楼 sorriest-siben 2013-06-03  
<aop:pointcut id="pointcut" expression="execution(* cn.javass..*.*(..))"/>
请问* cn.javass..*.*(..)这里,第一个星号和cn之间要空格,为什么呢?
23 楼 alan0509 2013-04-14  
alan0509 写道
alan0509 写道
alan0509 写道
没有 出现 ===========after finally advice 这句 是为什么?


没有报任何异常  也没有打印最后一句话

<aop:after method="afterFinallyAdvice" pointcut="execution(* testspring.aop..*.sayHello(..))" />

这个是我的配置,不知道问题出在哪


这是我后续的配置 <aop:config>
<aop:pointcut expression="execution(* testspring.aop..*.sayHello(..))"
id="pointcut" />
<aop:aspect ref="aspect">
<aop:before method="beforeAdvice" pointcut-ref="pointcut" />
<!--  匿名切入点 -->
<!-- <aop:after method="afterFinallyAdvice" pointcut-ref="execution(* testspring.aop..*.*(..))"/> -->
<aop:after method="afterFinallyAdvice" pointcut="execution(* testspring.aop..*.sayHello(..))" />
<aop:after-returning method="afterFinallyAdvice" pointcut="execution(* testspring.aop..*.sayHello(..))"  />
<aop:around method="aroundAdvice" pointcut="execution(* testspring.aop..*.sayAround(..))" />
</aop:aspect>
</aop:config>

我发现除了<aop:before> 工作外 其它的都不工作。代码是拷贝文中的代码


解决了 还以为是配置问题。是pom.xml文件出错了,然后好像程序一直停留在了上一个正确执行的状态。所以 无论怎么修改 总是看不到效果。

相关推荐

    跟开涛学Spring

    1.19 【第六章】 AOP 之 6.2 AOP的HelloWorld ——跟我学spring3 . . . . . . . . . . . . . . . . . . . . . . . . .208 http://jinnianshilongnian.iteye.com 第 2 / 366 页 1.20 【第六章】 AOP 之 6.3 基于...

    Spring的AOP示例DEMO HELLOWORLD

    本示例DEMO "Spring的AOP示例DEMO HELLOWORLD" 将引导我们深入理解Spring AOP的核心概念,并通过一个简单的 HelloWorld 示例来展示其实现过程。 首先,面向切面编程(AOP)是一种编程范式,旨在提高代码的可维护性...

    跟我学spring3

    《跟我学Spring3》是一本深入浅出的Spring框架学习指南,主要针对Spring 3.x版本进行详细讲解。Spring作为Java领域最流行的轻量级框架,它的应用广泛且功能强大,涵盖依赖注入、AOP(面向切面编程)、数据访问、Web...

    跟我学spring3pdf,高清

    《跟我学Spring3》是一本深入浅出的Spring框架学习指南,主要针对Spring 3.x版本进行讲解。这本书旨在帮助初学者和有一定经验的开发者更好地理解和应用Spring框架,提升其在实际开发中的技能。PDF文档提供了清晰的...

    跟我学spring

    标题“跟我学spring”和描述“spring 的使用,每个知识点和项目中的运用,20章的介绍。”暗示这是一份详细介绍Spring框架使用方法的教程或手册,覆盖了Spring的各个方面,并以实例为导向,深入探讨了每个知识点在...

    Spring4 HelloWorld

    Spring框架是Java开发中广泛使用的轻量级框架,它以其依赖...学习和理解"Spring4 HelloWorld",不仅能够帮助初学者掌握Spring的基本用法,也为进一步深入学习Spring的其他高级特性,如AOP、MVC、JPA等打下坚实基础。

    跟我学spring3(总共13章)8

    《跟我学Spring3》系列教程是为初学者和有经验的开发者提供的一份全面而深入的Spring框架学习资源。Spring3作为Java企业级应用开发的重要框架,它的核心特性包括依赖注入、AOP(面向切面编程)、数据访问、Web开发等...

    跟我学spring3(总共13章)6

    《跟我学Spring3》是针对初学者和有一定基础的开发者设计的一套全面、深入的教程,旨在帮助读者理解和掌握Spring3框架的核心概念和技术。本教程共计13个章节,覆盖了Spring3.0和3.x版本的主要特性。下面将详细阐述第...

    spring學習筆記——Helloworld

    在本篇“Spring学习笔记——HelloWorld”中,我们将探讨Spring框架的基础知识,以及如何创建一个简单的Spring应用程序。Spring是一个广泛使用的Java企业级应用开发框架,它提供了丰富的功能,包括依赖注入、AOP...

    跟我学Spring,Spring3学习资料

    - **AOP的HelloWorld:** 一个简单示例,通过实现一个切面来展示AOP的基本使用。 - **基于Schema的AOP和基于@AspectJ的AOP:** 两种不同的AOP实现方式,前者基于XML配置,后者是注解驱动的方式。 - **AspectJ切入点...

    9Spring AOP 盗梦空间之四——Around

    "9Spring AOP 盗梦空间之四——Around"这个标题暗示我们将深入探讨Spring AOP中的一个关键概念——环绕通知(Around Advice)。环绕通知是Spring AOP中功能最全面的通知类型,它提供了对方法执行前、执行后以及异常...

    跟我学spring3(1-13)

    《跟我学Spring3》是一本深入浅出介绍Spring框架的电子书,分为两部分,分别是“跟我学Spring3(8-13).pdf”和“跟我学Spring3(1-7).pdf”,全面覆盖了Spring框架的核心概念和技术。Spring作为Java开发中的主流框架,...

    死磕Spring之AOP篇 - Spring AOP两种代理对象的拦截处理(csdn)————程序.pdf

    Spring AOP 是一种面向切面编程的技术,它允许我们在不修改源代码的情况下,对应用程序的特定部分(如方法调用)进行增强。在 Spring 中,AOP 的实现主要依赖于代理模式,有两种代理方式:JDK 动态代理和 CGLIB 动态...

    五、Spring源码分析——Spring Aop

    《Spring AOP 源码分析》 在深入探讨Spring AOP之前,我们先要理解AOP(面向切面编程)的基本概念。AOP是一种编程范式,它将关注点分离,使得我们可以将横切关注点(如日志、事务管理、安全检查等)与业务逻辑解耦...

    跟我学Spring3

    《跟我学Spring3》这本书是针对Java开发人员深入学习Spring框架第三版的一份教程。Spring作为Java企业级应用开发中的核心框架,它以其强大的功能、灵活性和模块化设计深受开发者喜爱。Spring3版本在前一版本基础上...

    spring-aop.jar各个版本

    spring-aop-1.1.1.jar spring-aop-1.2.6.jar spring-aop-1.2.9.jar spring-aop-2.0.2.jar spring-aop-2.0.6.jar spring-aop-2.0.7.jar spring-aop-2.0.8.jar spring-aop-2.0.jar spring-aop-2.5.1.jar spring-aop-...

    Spring 入门案例——AOP

    Spring AOP(面向切面编程)是Spring框架的重要组成部分,它提供了一种模块化和声明式的方式来实现横切关注点,如日志、事务管理、性能监控等。本入门案例将帮助你理解并掌握Spring AOP的基本概念和使用方法。 在...

    跟我学spring3(1-7)

    《跟我学Spring3》系列教程涵盖了Spring框架的核心概念和技术,包括IoC(Inversion of Control,控制反转)、DI(Dependency Injection,依赖注入)、资源管理、Spring表达式语言(SpEL)以及面向切面编程(AOP)等...

Global site tag (gtag.js) - Google Analytics