spring:
datasource:
username: xxx
password: "xxxx"
url: jdbc:mysql://localhost:3306/xxx?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSl=false
driver-class-name: com.mysql.cj.jdbc.Driver
mybatis:
type-aliases-package: com.xxx.xxx #注册别名
mapper-locations: classpath:mybatis/mapper/*.xml #指定mapper所在位置
server:
#设置请求端口
port: 8080
servlet:
#指定 Tomcat的请求路径
context-path: /cl
#设置 Tomcat 编码格式
encoding:
charset: UTF-8
mybatis:
#加载 mapper.xml 文件到容器中
mapper-locations: classpath:mapper/*.xml
# 别名,简化 mapper.xml 中请求响应参数类型
type-aliases-package: com.cl.springboot.pojo
configuration:
#开启驼峰映射
map-underscore-to-camel-case: true
# sql日志的打印
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
spring:
datasource:
#mysql的配置加载驱动类信息
driver-class-name: com.mysql.jdbc.Driver
#mysql的连接信息
url: jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&serverTimezone = GMT
#用户名
username: root
#密码
password: 123456
# Type 设置使用何种类型的数据源
type: com.alibaba.druid.pool.DruidDataSource
#redis配置
redis:
database: 0
# Redis服务器地址
host: 127.0.0.1
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
password:
jedis:
pool:
# 连接池最大连接数(使用负值表示没有限制)
max-active: 8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1
# 连接池中的最大空闲连接
max-idle: 8
# 连接池中的最小空闲连接
min-idle: 0
# 连接超时时间(毫秒)默认是2000ms
timeout: 2000ms
#Druid 数据源属性配置 (需要创建数据源配置类,进行配置才会生效)
initialSize: 5
minIdle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
maxPoolPreparedStatementPerConnectionSize: 20
useGlobalDataSourceStat: true
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxx.mapper.xxxMapper">
<select id="selectBlog" resultType="Blog">
select * from Blog where id = #{id}
</select>
</mapper>
隐藏文件或者文件夹:
引用yml文件中数据:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> </dependency>
底线