能夠參考文章建立多模塊項目 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>