【Ruoyi】Some pitfalls encountered when using ruoyi

1. The controller cannot be scanned under multi-module mode.

1.1 Question

In the Ruoyi framework, you can see that there are controller and application under the ruoyi-admin module. Under the same package, application can scan the controller, but cannot scan the controller under rs-admin. When the front-end sends a request, 404 will appear.

Insert image description here

1.2 Solution

1.2.1 Add module dependencies

Add your own dependencies in ruoyi-admin
Insert image description here

1.2.2 Add scanBasePackages

Add the scanning package in @SpringBootApplication of Ruoyi's startup class. Pay attention to add Ruoyi's package name and the module package name written by yourself.
Insert image description here

2. Mapper cannot scan multiple modules

2.1 Question

The controller can be accessed in the self-defined module, but the mapper cannot be scanned

2.2 Solution

Add annotation @MapperScan to the startup class
Insert image description here

3. Unable to map entities in mapper.xml

3.1 Questions

The type in xml cannot be mapped successfully
Insert image description here

3.2 Solution

3.2.1 Write the full package name

Insert image description here

3.2.2 Modify typeAliasesPackage in yml

Add the package name of your own defined module to achieve automatic mapping
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_62726289/article/details/127127040