bob*_*jan 5 hibernate connector driver mariadb spring-boot
我有一个 SpringBoot 应用程序,可以与 MariaDB 连接器版本 2.7.6 很好地配合。我尝试将连接器升级到版本 3.0.6,但出现错误:
无法实例化[org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]:工厂方法“entityManagerFactory”抛出异常;嵌套异常是 java.lang.RuntimeException: Driver org.mariadb.jdbc.Driver 声称不接受 jdbcUrl, jdbc:mysql://localhost:3306/dbname
我的 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
Run Code Online (Sandbox Code Playgroud)
我的 Gradle 依赖项是
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'
}
Run Code Online (Sandbox Code Playgroud)
任何想法?
小智 8
从 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。
| 归档时间: |
|
| 查看次数: |
2887 次 |
| 最近记录: |