首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当连接器版本更改时,SpringBoot应用程序无法连接到MariDB

当连接器版本更改时,SpringBoot应用程序无法连接到MariDB
EN

Stack Overflow用户
提问于 2022-09-19 15:10:25
回答 1查看 275关注 0票数 1

我有一个SpringBoot应用程序,它可以很好地与MariaDB连接器2.7.6版本一起工作。我试图将连接器升级到3.0.6版本,但它引发了一个错误:

org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean:工厂方法'entityManagerFactory‘引发的异常实例化失败;嵌套的异常是java.lang.RuntimeException: Driver org.mariadb.jdbc.Driver声明不接受jdbcUrl

我的application.properties是:

代码语言:javascript
运行
复制
spring.datasource.url=jdbc:mysql://localhost:3306/dbname
spring.datasource.username=username
spring.datasource.password=password
spring.datasource.driverClassName=org.mariadb.jdbc.Driver

我的等级依赖关系是

代码语言:javascript
运行
复制
dependencies {
    testImplementation 'junit:junit:4.13.2'
    testImplementation('org.junit.vintage:junit-vintage-engine'){
        exclude group: 'org.hamcrest', module:'hamcrest-core'
    }
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation ('org.springframework.boot:spring-boot-starter-test'){
        exclude group: "com.vaadin.external.google", module:"android-json"
    }
    implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.6' // when 3.0.6 it is not working
    implementation 'org.json:json:20220320'
}

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2022-09-21 07:50:53

从3.0开始,MariaDB连接器默认只接受jdbc:mariadb前缀:

-- mysql和mariadb驱动程序有时在同一个类路径中可用,因此,现在,驱动程序默认只接受jdbc:mariadb:

如果出于某种原因,连接字符串必须是jdbc:mysql:驱动程序,只有当连接字符串包含“permitMysqlScheme”时才会使用。例子:jdbc:mysql:localhost/test?permitMysqlScheme.

https://mariadb.com/kb/en/mariadb-connector-j-303-release-notes/#jdbcmariadb-scheme

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73775617

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档