SpringBoot 分模块开发的操作方法

1、在原项目新增一个maven模块

SpringBoot 分模块开发的操作方法_第1张图片

选 maven ,不要选 spring initializr不然会覆盖掉原项目

SpringBoot 分模块开发的操作方法_第2张图片

2、新增的maven模块会出现在项目中,选配置pom文件


                                 //各个子项目,需要添加对parent 的依赖
        ruoyi   //parent项目中不存放任何代码,只是管理多个项目之间公共的依赖,即项目最外部的那个POM
        com.ruoyi
        3.8.1
    
    4.0.0
 
    stone  //模块名称
    
           //引用其它模块或组件,开发时用的到
        
            com.ruoyi
            ruoyi-common
        
    

 3、在父项目POM中加上新增模块的配置

           
            
                com.ruoyi
                ruoyi-common
                ${ruoyi.version}
            
 
              //这里添加新增的模块
                stone
        
    
    
        ruoyi-admin
        ruoyi-framework
        ruoyi-system
        ruoyi-quartz
        ruoyi-generator
        ruoyi-common
        stone  //这里注明引入的是模块
    

4、在主启动模块中引用模块

        
        
            com.ruoyi
            ruoyi-generator
        
          //主启动模块这里也加上去
        
            com.ruoyi
            stone
            3.8.1
        
    

 5、在主模块中配置SpringBoot的包扫描,使Controller可以用起来

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@ComponentScan(basePackages = {"com.ruoyi.*","com.ruoyi.stone.*"})  //这里需加入包扫描,否则启用不了新增模块里面的控制器等方法
public class RuoYiApplication
{
    public static void main(String[] args)
    {
        // System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(RuoYiApplication.class, args);

到此这篇关于SpringBoot 分模块开发的文章就介绍到这了,更多相关SpringBoot 分模块开发内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

你可能感兴趣的:(SpringBoot 分模块开发的操作方法)