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
发布评论