ion>
</dependency>
注册bean:
<!--注册bean-->
<bean id="userService" class="com.ws.service.UserServiceImpl"/>
<bean id="log" class="com.ws.log.Log"/>
<bean id="afterLog" class="com.ws.log.AfterLog"/>
方式一 :使用Spring的接口 【主要是SpringAPI接口实现】
<!--方式一:使用原生Spring API接口-->
<!--配置aop:需要导入aop的约束-->
<aop:config>
<!--切入点 expression :表达式 execution:要执行的位置-->
<aop:pointcut id="pointcut" expression="execution(* com.ws.service.UserServiceImpl.*(..))"/>
<!--执行环绕增加-->
<aop:advisor advice-ref="log" pointcut-ref="pointcut"/>
<aop:advisor advice-ref="afterLog" pointcut-ref="pointcut"/>
</aop:config>
方式二 :自定义类实现AOP (XML)【主要是切面定义】
<!--方式二:基于xml的声明式AspectJ-->
<bean id="diy" class="com.ws.diy.DiyPointCut"/>
<aop:config>
<!-- 自定义切面 ref:要引用的类-->
<aop:aspect ref="diy">
<!--切入点-->
<aop:pointcut id="pointcut" expression="execution(* com.ws.service.UserServiceImpl.*(..))"/>
<!--配置通知-->
<!--前置通知-->
<aop:before method="before" pointcut-ref="pointcut"/>
<!--后置通知-->
<aop:after method="after" pointcut-ref="pointcut"/>
<!--环绕通知-->
<aop:around method="around" pointcut-ref="pointcut"/>
<!--异常通知-->
<aop:after-throwing method="afterThrowing" pointcut-ref="pointcut" throwing="throwable"/>
<!--最终通知-->
<aop:after-returning method="afterReturning" pointcut-ref="pointcut"/>
</aop:aspect>
</aop:config>
方式三 :使用注解实现
<!--方式三:基于注解的声明式AspectJ-->
<bean id="annotationPointCut" class="com.ws.diy.AnnotationPointCut"/>
<!--开启注解支持 jdk(默认proxy-target-class="false") cglib(proxy-target-class="true")-->
<aop:aspectj-autoproxy proxy-target-class="true"/>
11. 整合mybatis
文档: https://mybatis.org/spring/zh/
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>spring-study</artifactId>
<groupId>com.hou</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-10-mybatis</artifactId>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.4</version>
</d