Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to distinguish between read and write separated data sources in mysql

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

How to distinguish between read-write separation data sources in mysql? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

The use of @ Aspect in AOP to monitor the execution of the program

The AOP annotations used by Spring are divided into three levels:

The prerequisite is to release it in xml.

1. @ Aspect is placed on top of the class header, using the class as an aspect.

2. @ Pointcut is placed on the method header to define a pointcut expression that can be referenced by other methods.

3. 5 kinds of notices.

3.1, @ Before, pre-notification, put on the method header.

3.2, @ After, post [finally] notification, and put it on the method header.

3.3. @ AfterReturning, followed by [try] notification, put on the method header, and use returning to refer to the method return value.

3.4. @ AfterThrowing, followed by [catch] notification, put on the method header, and use throwing to refer to the thrown exception.

3. 5, @ Around, surround the notification and put it on the head of the method, which determines whether the actual method executes or not and must have a return value.

@ Component

@ Aspect

Public class LogAspect {

/ * *

* the name that defines Pointcut,Pointcut is simplePointcut. This method cannot have a return value, it is just an indication.

, /

@ Pointcut ("execution (public * com.service.impl..*.* (..)")

Public void recordLog () {

}

@ AfterReturning (pointcut = "recordLog ()")

Public void simpleAdvice () {

LogUtil.info ("AOP post-processing succeeded")

}

@ Around ("recordLog ()")

Public Object aroundLogCalls (ProceedingJoinPoint jp) throws Throwable {

LogUtil.info ("normal operation")

Return jp.proceed ()

}

@ Before ("recordLog ()")

Public void before (JoinPoint jp) {

String className = jp.getThis () .toString ()

String methodName = jp.getSignature () .getName (); / / get the method name

LogUtil.info ("at:" + className + "call" + methodName + "() method-start!")

Object [] args = jp.getArgs (); / / get the parameter list

If (args.length

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report