alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
27.9k stars 8.57k forks source link

Druid configures Error #5834

Closed JunSilckTar closed 5 months ago

JunSilckTar commented 5 months ago

druid-spring-boot-starter version: 1.2.22 Springboot version: 2.6.13

Ktorm version: 3.6.0 dbType: mysql dbVersion: 8.0

Hi, I got a error when I run application with not set url for spring.database, like this

spring:
  datasource:
   # url: jdbc:mysql://localhost:3306

I set excuse for @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) kotlin: @SpringBootApplication(exclude = [DataSourceAutoConfiguration.class])

the error is " Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. "

But it is working if I set url, like this, and there is a connection on web! like this

spring:
  datasource:
    url: jdbc:mysql://localhost:3306
截屏2024-04-09 13 37 38

I use that way to configure DruidDataSource, other connection is correct

截屏2024-04-09 13 37 59

I must set url for springboot.database else class org.springframework.boot.autoconfigure.jdbc.DataSourceBeanCreationException Failed to determine a suitable driver class. if I don't use druid, the error not come out

I wondering not put any configuration on application.properties or yaml, Is there a problem with my operation or a bug? I can't test

Thank you for your working!!! Regards.

JunSilckTar commented 5 months ago

sorry, I use that way to configure DruidDataSource, other connection is correct

        val druidDataSource = DruidDataSource()
        druidDataSource.url = url
lizongbo commented 5 months ago

spring:
  datasource:
    url: jdbc:mysql://localhost:3306
    type: com.alibaba.druid.pool.DruidDataSource