日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

Spring AOP XML配置及注解配置

發(fā)布時(shí)間:2024/10/6 asp.net 373 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring AOP XML配置及注解配置 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

一.XML配置切面類

1.日志切面類

//切面類注解配置加兩個(gè)注解 @Aspect @Component public class LoggerAspect {public Object log(ProceedingJoinPoint joinPoint) throws Throwable {System.out.println("start log:" + joinPoint.getSignature().getName());Object object = joinPoint.proceed();System.out.println("end log:" + joinPoint.getSignature().getName());return object;} }

2.業(yè)務(wù)類

//業(yè)務(wù)類 @Component public class ProductService {public void doSomeService(){System.out.println("doSomeService");} }

3.spring.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:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"><!-- 注解方式aop--><component-scan base="ServiceClass"/><component-scan base="LoggAspect"/><aop:aspectj-autoproxy/><!--xml配置aop--><bean id="productService" class="service"/><bean id="loggerAspect" class="LoggerAspect"><aop:config><aop:pointcut id="pointCut" expression="execution(* package.class.*(..))"<aop:aspect id="logAspect" ref="loggerAspect"><aop:round method="log" ref="pointcut"></aop:aspect></aop:config></beans>

?

?

?

總結(jié)

以上是生活随笔為你收集整理的Spring AOP XML配置及注解配置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。