SpringBoot整合Druid报Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded

编程入门 行业动态 更新时间:2024-10-09 04:25:38

SpringBoot整合Druid报<a href=https://www.elefans.com/category/jswz/34/1770925.html style=Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded"/>

SpringBoot整合Druid报Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded

1、问题描述

***************************
APPLICATION FAILED TO START
***************************Description:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.Reason: Failed to determine a suitable driver classAction:Consider the following:If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).Process finished with exit code 1

2、错误原因
在yaml这配置文件中的顺序写错了,过于粗心

错误:

spring:thymeleaf:cache: falsemessages:basename: i18n.loginmvc:format:date: yyyy-MM-ddserver:port: 8081servlet:context-path: /mmcdatasource:username: rootpassword: 123456url: jdbc:mysql://localhost:3306/db_mytest?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMTdriver-class-name: com.mysql.cj.jdbc.Drivertype: com.alibaba.druid.pool.DruidDataSourceinitialSize: 5minIdle: 5maxActive: 20maxWait: 60000timeBetweenEvictionRunsMillis: 60000minEvictableIdleTimeMillis: 300000validationQuery: SELECT 1 FROM DUALtestWhileIdle: truetestOnBorrow: falsetestOnReturn: falsepoolPreparedStatements: truefilters: stat,wall,log4jmaxPoolPreparedStatementPerConnectionSize: 20useGlobalDataSourceStat: trueconnectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500

ymal配置文件有严格的规范,换行空格错误,将
Druid数据源的配置放在了server下,应该放在spring下的~

正确:


spring:thymeleaf:cache: falsemessages:basename: i18n.loginmvc:format:date: yyyy-MM-dddatasource:username: rootpassword: 123456url: jdbc:mysql://localhost:3306/db_mytest?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMTdriver-class-name: com.mysql.cj.jdbc.Drivertype: com.alibaba.druid.pool.DruidDataSourceinitialSize: 5minIdle: 5maxActive: 20maxWait: 60000timeBetweenEvictionRunsMillis: 60000minEvictableIdleTimeMillis: 300000validationQuery: SELECT 1 FROM DUALtestWhileIdle: truetestOnBorrow: falsetestOnReturn: falsepoolPreparedStatements: truefilters: stat,wall,log4jmaxPoolPreparedStatementPerConnectionSize: 20useGlobalDataSourceStat: trueconnectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500server:port: 8081servlet:context-path: /mmc

程序正确运行

更多推荐

SpringBoot整合Druid报Failed to configure a DataSource: ‘url‘ attribute is not speci

本文发布于:2024-02-27 19:04:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1765781.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Failed   configure   SpringBoot   Druid   attribute

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!