spring Sping Boot Maria DB连接|无法确定合适的驱动程序类

lmvvr0a8  于 2023-06-04  发布在  Spring
关注(0)|答案(1)|浏览(313)

我想添加一个mariaDB数据库连接到我的spring Boot 应用程序。
我这样定义application.properties:

#mariaDB Connection
spring.datasource.url=jdbc:mariadb://localhost:3306/database
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.hibernate.ddl-auto=create-drop

但我得到以下错误:

***************************
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 class

Action:

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).

数据库依赖性

<!-- ===============
             == MariaDB
             =============== -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mariadb.jdbc</groupId>
            <artifactId>mariadb-java-client</artifactId>
            <version>1.5.7</version>
        </dependency>

有人有任何想法,我需要改变什么,连接将工作?

e5njpo68

e5njpo681#

根据你的mariadb驱动程序的版本,我敢打赌你已经使用了springframework guru's guide。该指南使用springboot 1.4.4,所以我的第二个赌注是你的问题是版本不匹配。如果你使用的是springboot parent 3.X.X,我建议你试试mariadb java client version 3.1.4/3.1.0。

相关问题