junit spring and integration testing
The first step guide package
Package guide 4 + 2 + aop + test
Step Configuration Note:
Establish a demo02
then
Adhesive
The spring aop
aop thought:
Who the things the code needs to be extracted with whom
The concept of spring aop:
aop term study
Where things can be managed is called the connection point
The preparation adds something called entry point management methods
Content management to configuration method called enhanced code
The last generation with a good thing called proxy object (invisible intangible)
Notification application is something content, preparation method is the entry point to the things you want to manage, when you take things to the starting point when the contents of the configuration is called weaving
Has been fully configured object is called a proxy object
The spring aop demo
1. Package guide:
2. Prepare the target object
3. Prepare notice
4. configuration weaving, woven into the notification target object
To build relationships
Then paste
< AOP: config > <-! Configuration entry point public void com.oracle.service.UserServiceImp.save() void com.oracle.service.UserServiceImp.save() * com.oracle.service.UserServiceImp.save() * com.oracle.service.UserServiceImp.*() * com.oracle.service.*ServiceImp.*(..) --> <aop:pointcut expression="execution(* com.oracle.service.*ServiceImp.*(..))" id="pc"/> <aop:aspect ref="myAdvice"> <!--指定名为before的方法作为前置通知 --> <aop:before method="before" pointcut-ref="pc"/> <!--后置 --> <aop:after-returning method="afterReturning" pointcut-ref="pc"/> <!--环绕通知 --> <aop:around method="around" pointcut-ref="pc"/> <!--异常拦截通知 --> <aop:after-throwing method="afterException" pointcut-ref="pc"/> <!--后置 --> <aop:after method="after" pointcut-ref="pc"/> </aop:aspect> </aop:config>
Inside the method and the method name must
Like the job