一、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: 8081servlet:session:timeout: 10spring: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%2B8username: rootpassword: root# 从库数据源master2:# 从数据源开关/默认关闭enabled: truejdbcurl: jdbc:sqlserver://localhost:1433;DatabaseName=ckywusername: apassword: athymeleaf:prefix: classpath:/templates/suffix: .htmlmode: HTML5encoding: UTF-8content-type: text/htmlcache: false
# web:
# resources:
# static-locations: classpath:/static/mybatis:mapper-locations: classpath:mappers/*.xmltype-aliases-package: com.hs.entityconfiguration:#开启驼峰map-underscore-to-camel-case: truecache-enabled: truelogging:level:com:hs:dao : debugupload_url : d:/uploads/
三、启动类 SpringBootApplication.java 加 @MapperScan("com.hs.dao")注解
注意:mapper.xm路径一般在resource下面