今天使用springboot中出现以下问题:
查了一些资料发现问题出现的原因有种:
1.注释错误引起 : application.yml采用的是#注释而不是//
2.配置信息中冒号后面必须要有空格
查看错误下面的定位信息:属于第二种
记录一下。
附application.yml基本配置信息
#简单配置
#spring:
# datasource:
# url: jdbc:mysql://127.0.0.1:3306/springboot?characterEncoding=utf8
# driverClassName: com.mysql.jdbc.Driver
# username: root
# password: root
# jpa:
# database: MySQL
# show-sql: true
# hibernate:
# naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
#支持druid数据库连接池配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/springboot?characterEncoding=utf8
username: root
password: root
#最大活跃数
maxActive: 20
#初始化数量
initialSize: 1
#最大连接等待超时时间
maxWait: 60000
#打开PSCache,并且指定每个连接PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
#通过connectionProperties属性来打开mergeSql功能;慢SQL记录
#connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 1 from dual
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
#配置监控统计拦截的filters,去掉后监控界面sql将无法统计,'wall'用于防火墙
filters: stat, wall, log4j
jpa:
properties:
hibernate:
show_sql: true
format_sql: true
redis:
host: 127.0.0.1
port: 6379
pool:
max-idle: 20
min-idle: 1
max-active: 20
max-wait: 60000
database: 0