能够参考文章建立多模块项目 Go!!!java
项目分3个子模块分别是,父级megatronmysql
package com.megatron.module; import com.megatron.utils.IPUtils; import org.mybatis.spring.annotation.MapperScan; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @MapperScan("com.megatron.module.dal.mapper") //扫描指定包中的接口 public class MegatronLogApiApplication { public static Logger logger = LoggerFactory.getLogger(MegatronLogApiApplication.class); public static void main(String[] args) { System.setProperty("local-ip", IPUtils.getLocalIp()); SpringApplication.run(MegatronLogApiApplication.class, args); } }
application.ymlgit
spring: datasource: name: mysql type: com.alibaba.druid.pool.DruidDataSource druid: filter: stat driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://127.0.0.1:3306/megatron?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true username: root password: #配置初始化大小/最小/最大 initial-size: 1 min-idle: 1 max-active: 20 #获取链接等待超时时间 max-wait: 60000 #间隔多久进行一次检测,检测须要关闭的空闲链接 time-between-eviction-runs-millis: 60000 #一个链接在池中最小生存的时间 min-evictable-idle-time-millis: 300000 validation-query: SELECT 'x' test-while-idle: true test-on-borrow: false test-on-return: false #打开PSCache,并指定每一个链接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false pool-prepared-statements: false max-pool-prepared-statement-per-connection-size: 20 logging: config: classpath:log4j2-test.yml mybatis: mapper-locations: classpath:mapper/*.xml type-aliases-package: com.megatron.module.dal.entity
<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <!-- 分页插件 --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.5</version> </dependency> <!-- alibaba的druid数据库链接池 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.9</version> </dependency>