小同事新建了一个springboot项目,初始化启动却报错:
Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could。
数据源用的druid,初始化数据源使用springboot autoconfigure,看了一下他的yml文件,还是对自动配置不熟悉。
spring:
druid:
driverClassName: com.mysql.cj.jdbc.Driver
既然使用druid自动配置,就要遵循自动配置的约定,带他看了下druid-spring-boot-starter,属性对应不上,自然无法初始化了。
属性调整下正常了。
spring:
datasource:
druid:
driverClassName: com.mysql.cj.jdbc.Driver