软件编程
位置:首页>> 软件编程>> java编程>> SpringBoot导入Druid运行失败问题

SpringBoot导入Druid运行失败问题

作者:weixin_45551504  发布时间:2023-02-14 03:35:41 

标签:SpringBoot,导入,Druid

创建SpringBoot项目在引入Druid之后,根据视频中的教程在application.yaml文件中添加了一些配置
(下面的代码是不合乎规范的,因为没有对齐)


spring:
datasource:
  #Spring Boot 默认是不注入这些属性值的,需要自己绑定
  #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,stat:监控统计、log4j:日志记录、wall:防御sql注入
  #如果允许时报错 java.lang.ClassNotFoundException: org.apache.log4j.Priority
  #则导入 log4j 依赖即可,Maven 地址:https://mvnrepository.com/artifact/log4j/log4j
  filters: stat,wall,log4j
  maxPoolPreparedStatementPerConnectionSize: 20
  useGlobalDataSourceStat: true
  connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500

结果在运行的时候,出现了这样的错误

SpringBoot导入Druid运行失败问题

后来发现是yml文件的错误,因为在红色格格的地方应该适合上面的在同一格局下的,让这里项前进一个格格就可以了

SpringBoot导入Druid运行失败问题

这个网址能检测自己的yml文件的书写有没有格式的错误
http://www.bejson.com/validators/yaml_editor/
或者点这里

来源:https://blog.csdn.net/weixin_45551504/article/details/108435087

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com