---
title: "使用Spring的注解方式实现AOP入门"
author: "cuiran"
date: "2009-10-14T21:34:53Z"
tags: []
slug: "spring-aop"
draft: false
lastmod: "2009-10-14T21:34:53Z"
id: 489414
url: "https://cuiran.iteye.com/blog/489414"
---

beans.xml文件如下

&lt;?xml version="1.0" encoding="UTF-8"?&gt;  
&lt;beans xmlns="[http://www.springframework.org/schema/beans](http://www.springframework.org/schema/beans)"  
       xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)"  
       xmlns:context="[http://www.springframework.org/schema/context](http://www.springframework.org/schema/context)"  
       xmlns:aop="[http://www.springframework.org/schema/aop](http://www.springframework.org/schema/aop)"       
       xsi:schemaLocation="[http://www.springframework.org/schema/beans](http://www.springframework.org/schema/beans)  
           [http://www.springframework.org/schema/beans/spring-beans-2.5.xsd](http://www.springframework.org/schema/beans/spring-beans-2.5.xsd)  
           [http://www.springframework.org/schema/context](http://www.springframework.org/schema/context) [http://www.springframework.org/schema/context/spring-context-2.5.xsd](http://www.springframework.org/schema/context/spring-context-2.5.xsd)  
           [http://www.springframework.org/schema/aop](http://www.springframework.org/schema/aop) [http://www.springframework.org/schema/aop/spring-aop-2.5.xsd](http://www.springframework.org/schema/aop/spring-aop-2.5.xsd)"&gt;  
        &lt;aop:aspectj-autoproxy/&gt;  
        &lt;bean id="myInterceptor" class="org.springaop.service.MyInterceptor"/&gt;  
        &lt;bean id="personService" class="org.springaop.service.impl.PersonServiceBean"/&gt;  
&lt;/beans&gt;

 

工程详见附件！