[SpringBoot] 81. SpringBoot multi-module project integrates MyBatis-Plus to dynamically obtain IService objects

1. Article description

In multi-module projects, we put the codes of different businesses in different modules. My approach is to put the database objects in the model module, and then the database objects of each business module are divided into multiple sub-modules in the model module, as follows is my project structure

  • bt-common
  • bt-model
    • bt-model-order
    • bt-model-product
    • bt-model-system
  • bt-order
  • bt-product
  • bt starter
  • bt-system

The bt-model module stores the database objects of each module, and each business module is independent of each other.

2. Source of problem

If we need to query product information in bt-order, we need to introduce bt-product. If we need to count related orders in bt-product, we need to introduce bt-order. In this way, interdependence problems arise.

3. Solution

  • 1. Obtain IService object

Create a tool class in bt-common with the following code:

import com.baomidou.mybatisplus.ex

Guess you like

Origin blog.csdn.net/qq_40065776/article/details/131455254