标签:ram connect work druid 方式 from 数据源 epo end
1.idea新建多模块springBoot项目
父项目使用maven的方式创建
创建完成 删掉src目录
新增子模块使用springBoot initializer插件创建
按以上步骤再建module2 和 main
因为父项目用的是maven方式 所以自己修改父项目pom文件 增加druid、mybatisPlus等依赖和module标签 以下是修改后的parent 的pom文件
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.0.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>cn.gch</groupId> <artifactId>druid-parent</artifactId> <version>1.0</version> <packaging>pom</packaging> <name>druid-parent</name> <modules> <module>druid-main</module> <module>druid-module1</module> <module>druid-module2</module> </modules> <properties> <java.version>1.8</java.version> </properties> <dependencies> <!-- mybatis-plus begin --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.1.1</version> </dependency> <!-- mybatis-plus end --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.10</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> </dependencies> </project>
子模块继承父模块 这里例出main模块的pom
在springBoot框架下使用druid+myBatisPlus实现多数据源(不同模块不同数据源)
标签:ram connect work druid 方式 from 数据源 epo end
原文地址:https://www.cnblogs.com/guanxiaohe/p/11806875.html