我有一个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是:
spring.datasource.url=jdbc:mysql://localhost:3306/dbname
spring.datasource.username=username
spring.datasource.password=password
spring.datasource.driverClassName=org.mariadb.jdbc.Driver我的等级依赖关系是
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'
}有什么想法吗?
发布于 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。
https://stackoverflow.com/questions/73775617
复制相似问题