一、pom.xml
<!--mysql驱动包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--springboot与JDBC整合包-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!--springboot与mybatis的整合包-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
二、application.yml
server:
port: 8081
servlet:
session:
timeout: 10
spring:
servlet:
multipart:
max-file-size: 50MB #单个文件最大限制
max-request-size: 100MB #多个文件最大限制
# 数据源配置
datasource:
# 主库数据源
master1:
jdbcurl: jdbc:mysql://localhost/plc_xz?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: root
# 从库数据源
master2:
# 从数据源开关/默认关闭
enabled: true
jdbcurl: jdbc:sqlserver://localhost:1433;DatabaseName=ckyw
username: a
password: a
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: HTML5
encoding: UTF-8
content-type: text/html
cache: false
# web:
# resources:
# static-locations: classpath:/static/
mybatis:
mapper-locations: classpath:mappers/*.xml
type-aliases-package: com.hs.entity
configuration:
#开启驼峰
map-underscore-to-camel-case: true
cache-enabled: true
logging:
level:
com:
hs:
dao : debug
upload_url : d:/uploads/
三、启动类 SpringBootApplication.java 加 @MapperScan("com.hs.dao")注解
注意:mapper.xm路径一般在resource下面