If RuoYi-Vue adds a new sub-module module, the interface of the sub-module will report 404, and how to ensure correct scanning after customizing the package name?

Reference for the process of creating a submodule module: click to jump

Note that after creating a submodule, you need to add submodule dependencies to pom.xml in the root directory and pom.xml in the startup module.

How to ensure correct scanning after customizing the package name?

The package scanning of springboot is configured by default as the package where the startup class is located, and its sub-packages, so everything placed under the com.ruoyi package can be scanned.
After customizing the package name, you need to add @MapperScan and @ComponentScan in the startup class to realize all package scanning.

/**
 * 启动程序
 */
@SpringBootApplication(exclude = {
    
     DataSourceAutoConfiguration.class })
@MapperScan(value = {
    
    "com.test.*.mapper","com.ruoyi.*.*.mapper"})
@ComponentScan(value = {
    
    "com.test","com.ruoyi"} )
public class Application
{
    
    
    public static void main(String[] args)
    {
    
    
        SpringApplication.run(Application.class, args);
        System.out.println("启动成功");
    }
}

The newly added submodule entity needs to add the entity scan of the submodule in application.yml in mybatis - typeAliasesPackage

mybatis-plus:
  # 对应的 XML 文件位置
  mapper-locations: classpath*:mapper/**/*Mapper.xml
  # 实体扫描,多个package用逗号或者分号分隔
  typeAliasesPackage: com.ruoyi.**.domain,com.test.*.*.entity

Guess you like

Origin blog.csdn.net/god_sword_/article/details/122390623