The invention discloses a real-
time table synchronization method based on spring and myabits frameworks, which belongs to the technical field of
data processing, and comprises the following steps: extracting a table name from an
sql statement, and setting a synchronization table
list to an
sql context manager according to the table name; the mybatis layer interceptor obtains a result of executing the
sql statement by using the main
data source and returns the result to the Dao layer interceptor, and a synchronization table
list is extracted from the sql
context manager; the Dao layer interceptor sets a slave
library code in an sql
context manager; a slave
library connection is obtained according to a slave
library code set in the sql context manager, the mybatis layer interceptor uses the slave library connection to execute the sql statement, and
data synchronization is carried out on a slave library corresponding to the slave library connection; and after all library synchronization operations are completed, returning an execution result to a dao layer method name by the dao layer interceptor. According to the real-
time table synchronization method based on spring and myabits frameworks, the problems that in an existing table synchronization method, a
programmer needs to write service codes additionally,
delay exists, and table synchronization is difficult to conduct between different databases are solved.