栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

SpringBoot基于Maven多模块开发

SpringBoot基于Maven多模块开发

目录

pom.xml

multi_modulecommonscheduleserverflink common作为DAO层,包含server和schedule共用的service层

serverschedule

multi_module
    -common
    -schedule(依赖common)
    -server(依赖common)
    -flink
pom.xml multi_module


    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.4.1
         
    

    org.example
    multi_module
    pom
    1.0-SNAPSHOT
    
        common
        server
        schedule
        flink
    

    
        8
        8
    

common


    
        multi_module
        org.example
        1.0-SNAPSHOT
    
    4.0.0
    common
    1.0-SNAPSHOT
    common
    
        8
        8
    
    
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            2.1.4
        

        
            mysql
            mysql-connector-java
            runtime
        
    

schedule


    
        multi_module
        org.example
        1.0-SNAPSHOT
    
    4.0.0

    schedule
    
        
            org.example
            common
            1.0-SNAPSHOT
            compile
        

        
            org.springframework.boot
            spring-boot-starter
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        

        
            org.springframework.boot
            spring-boot-starter-web
        
    

    
        8
        8
    

server


    
        multi_module
        org.example
        1.0-SNAPSHOT
    
    4.0.0

    server

    
        8
        8
    

    
        
            org.example
            common
            1.0-SNAPSHOT
        

        
            org.springframework.boot
            spring-boot-starter-web
        

        
            org.springframework.boot
            spring-boot-starter
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

flink


    
        multi_module
        org.example
        1.0-SNAPSHOT
    
    4.0.0

    flink

    
        8
        8
    

    
        
            org.springframework.boot
            spring-boot-starter
        
    

common作为DAO层,包含server和schedule共用的service层

其中需要在server和schedule的启动类上添加@ComponentScan注解。

server
package org.example.server;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@MapperScan("org.example.common.mapper")
@ComponentScan("org.example.common.service")
@ComponentScan("org.example.server.service")
@ComponentScan("org.example.server.controller")
@SpringBootApplication
public class ServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ServerApplication.class, args);
    }
}
schedule
package org.example.schedule;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan("org.example.common.service")
@ComponentScan("org.example.schedule.proc")
public class ScheduleApplication {
    public static void main(String[] args) {
        SpringApplication.run(ScheduleApplication.class, args);
    }
}

代码位置

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/721769.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号