application.yml
server:
tomcat:
uri-encoding: UTF-8
spring:
profiles:
active: dev
datasource:
driver-class-name: com.mysql.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
druid: # 阿里巴巴druid 数据库连接池
initial-size: 20
max-active: 100
max-wait: 60000
min-idle: 1
min-evictable-idle-time-millis: 300000
time-between-eviction-runs-millis: 60000
validation-query: select 'x'
test-on-borrow: false
test-on-return: false
test-while-idle: true
pool-prepared-statements: true
max-open-prepared-statements: 20
async-init: true
stat-view-servlet:
enabled: false
web-stat-filter:
enabled: false
thymeleaf:
cache: false
mode: LEGACYHTML5
prefix: classpath:/templates/
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
# mybatis 配置
mybatis:
mapper-locations: classpath*:mapper/*.xml
# mybatis 分页插件
pagehelper:
helper-dialect: mysql
reasonable: true
support-methods-arguments: "true"
params: count=countSql
# mybatis 通用 mapper
mapper:
identity: 'SELECT GUID()'
before: true
not-empty: true
mappers:
- tk.mybatis.mapper.common.Mapper
- tk.mybatis.mapper.additional.insert.InsertListMapper
logging:
level:
com.xiaowei.baihui: debug
org.apache.ibatis: debug
# file:
# max-size : 100KB #配置日志最大大小
# max-history : 30 #保留30天的日志
#logging:
# config: classpath:log-config.xml
application-dev.yml
spring:
datasource:
url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
username: root
password: 123456
maven依赖:
<?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>
<groupId>com.learning</groupId>
<artifactId>gao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>gao</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.16.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>