Multi-threaded Concurrent Programming Study Notes 11 (XiaoDi Classroom) Data Synchronization Interface

 

 

 Intermediate table design:

We originally had a student table.

 Then we go to design the intermediate table:

 Basic environment construction:
Since we are building an environment, we must start with maven and introduce dependencies:

Then we need to configure our mybatis xml file.

We also need to configure the database of the intermediate table:

We only need to change the database name to middle.

In this way, our mybatis configuration is over.

 We also use classes to create our database connection pool.

We also need to use sqlSession to connect to the database, so we need to write our tool class:

 In this way, our basic environment is created.

Producer coding implementation:
We first need to change the field in the database table, id, to int type and increment by itself, and then change the birth type to datetime type.

We need to remember to close the stream.

Entity class:

 

mapper:

 xml:

 

service:

impl:

Notice:

After we created the mapper, we also need to configure the mapper in the mybatis file:

We add a piece of data to the intermediate table of the database:

Let’s use the test class to test it now:
 

Then let’s test the modifications:

Status change successful.

We set the state to an intermediate class:

 We need to create a consumer:

Then we go and complete our producer code:

Our producer code is complete, now let’s write our consumer code:

 Let's now create an interface just for processing data:

Our dao and mapper.xml of our layer are the same as middle.

Then we write the implementation class for processing data:

 

We can add the log configuration file:

Run class:

run:

We cleared the student table of the lx library before, and we found that the table data was successfully assigned.

 

Guess you like

Origin blog.csdn.net/weixin_52618349/article/details/130331592