未设置'hibernate.dialect'时,对方言解析信息的访问不能为空/多个数据库



Spring启动应用程序。我有这个数据源:

package _ourapp_.vTiger
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.jdbc.DataSourceBuilder
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.data.jpa.repository.config.EnableJpaRepositories
import org.springframework.orm.jpa.JpaTransactionManager
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
import org.springframework.stereotype.Component
import javax.sql.DataSource
@Configuration
@Component("_ourapp_.vTiger")
@EnableJpaRepositories(
basePackages = ["_ourapp_.vTiger"],
entityManagerFactoryRef = "vTigerEntityManager",
transactionManagerRef = "vTigerTransactionManager"
)
open class DataSource {
@Bean
@ConfigurationProperties(prefix = "database.vtiger")
open fun calldata_base(): DataSource = DataSourceBuilder.create().build()
@Bean
open fun vTigerEntityManager(): LocalContainerEntityManagerFactoryBean =
(LocalContainerEntityManagerFactoryBean()).apply {
dataSource = calldata_base()
setPackagesToScan("_ourapp_.vTiger.model")
jpaVendorAdapter = HibernateJpaVendorAdapter()
}
@Bean
open fun vTigerTransactionManager() = JpaTransactionManager(vTigerEntityManager().`object`!!)
}

and in application.properties:

database.vtiger.jdbc-url=jdbc:mariadb://_ourdatabaseinstance_.rds.amazonaws.com:3306
database.vtiger.user=_ourname_
database.vtiger.username=_ourname_
database.vtiger.password=_ourpass_
database.vtiger.maximum-pool-size=5
database.vtiger.driver-class-name=org.mariadb.jdbc.Driver
database.vtiger.database-platform=org.hibernate.dialect.MariaDBDialect
database.vtiger.dialect=org.hibernate.dialect.MariaDBDialect
hibernate.dialect=org.hibernate.dialect.MariaDBDialect

,因为我们的应用程序有另一个数据库,这里省略了。

正在连接一个AWS Aurora实例,引擎版本5.6.mysql_aurora.1.22.5

应用程序启动失败,包含多个消息

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vTigerEntityManager' defined in class path resource [au/com/ngv/kitten/vTiger/DataSource.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

(这就是为什么我在上面引用了特定的来源,因为其中定义了vTigerEntityManager),但最后是可怕的

Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

我正在使用MariaDB,因为IntelliJ数据库连接工具推荐它而不是MySQL驱动程序。

怎么能冬眠。当明显是时,方言"未设置"在application.properties中设置?

如果它是相关的,我在IntelliJ本身使用这个解决方案。当我在IntelliJ中运行应用程序时发生错误。

这是在application.properties中设置的正确变量:

spring.jpa.properties.hibernate.dialect 

最新更新