pom.xml
multi_modulecommonscheduleserverflink common作为DAO层,包含server和schedule共用的service层
serverschedule
multi_module
-common
-schedule(依赖common)
-server(依赖common)
-flink
pom.xml
multi_module
common4.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
schedulemulti_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
servermulti_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
flinkmulti_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
common作为DAO层,包含server和schedule共用的service层multi_module org.example 1.0-SNAPSHOT 4.0.0 flink 8 8 org.springframework.boot spring-boot-starter
其中需要在server和schedule的启动类上添加@ComponentScan注解。
serverpackage 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);
}
}
代码位置



