spring mysql hibernate.dialect_springboot启动失败的问题('hibernate.dialect' not set)

该博客讲述了如何解决Spring Boot 1.3.0.M1应用在连接MySQL 8时启动报'hibernate.dialect'未设置的错误,通过在properties文件中添加database-platform属性并指定MySQLDialect,解决了问题。
摘要由CSDN通过智能技术生成

springboot启动失败的问题('hibernate.dialect' not set)

发布时间:2018-02-21 12:03,

浏览次数:919

, 标签:

springboot

hibernate

dialect

not

set

springboot版本是1.3.0.M1

,连接的mysql版本为8,用spring-boot-starter-data-jpa操做数据库,启动springboot报错如下:

2018-02-21 11:25:47.637 WARN 12992 --- [ main]

ationConfigEmbeddedWebApplicationContext : Exception encountered during context

initialization - cancelling refresh attempt

org.springframework.beans.factory.BeanCreationException: Error creating bean

with name'entityManagerFactory' defined in class path resource

[org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]:

Invocation of init method failed; nested exception is

org.hibernate.HibernateException: Access to DialectResolutionInfo cannot benull

when'hibernate.dialect' not set at

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:

1578) at

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:

545) at

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:

482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.

getObject(AbstractBeanFactory.java:304) at

org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:

230) at

org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:

300) at

org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:

195) at

org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:

1011) at

org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:

802) at

org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:

521) at

org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:

118) at

org.springframework.boot.SpringApplication.refresh(SpringApplication.java:678)

at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:339)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:274)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:931)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:920)

at com.business.backend.BizApplication.main(BizApplication.java:122) Caused by:

org.hibernate.HibernateException: Access to DialectResolutionInfo cannot benull

when'hibernate.dialect' not set at

org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:

104) at

org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:

71) at

org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:

205) at

org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:

111) at

org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:

234) at

org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:

206) at

org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.

perform(EntityManagerFactoryBuilderImpl.java:857) at

org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.

perform(EntityManagerFactoryBuilderImpl.java:850) at

org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:

425) at

org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:

849) at

org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:

60) at

org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:

343) at

org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:

318) at

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:

1637) at

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:

1574) ... 16 common frames omitted 2018-02-21 11:25:47.647 INFO 12992 --- [

main] o.apache.catalina.core.StandardService : Stopping service Tomcat

这一句比较关键:

Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

原来是Hibernate SQL方言没有设置导致的,在properties文件中增加下面这行:

spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect

再启动springboot,这次启动成功了;

将Hibernate SQL方言整理如下表:

数据库 方言

DB2 org.hibernate.dialect.DB2Dialect

DB2 AS/400 org.hibernate.dialect.DB2400Dialect

DB2 OS390 org.hibernate.dialect.DB2390Dialect

PostgreSQL org.hibernate.dialect.PostgreSQLDialect

MySQL org.hibernate.dialect.MySQLDialect

MySQL with InnoDB org.hibernate.dialect.MySQLInnoDBDialect

MySQL with MyISAM org.hibernate.dialect.MySQLMyISAMDialect

Oracle (any version) org.hibernate.dialect.OracleDialect

Oracle 9i/10g org.hibernate.dialect.Oracle9Dialect

Sybase org.hibernate.dialect.SybaseDialect

Sybase Anywhere org.hibernate.dialect.SybaseAnywhereDialect

Microsoft SQL Server org.hibernate.dialect.SQLServerDialect

SAP DB org.hibernate.dialect.SAPDBDialect

Informix org.hibernate.dialect.InformixDialect

HypersonicSQL org.hibernate.dialect.HSQLDialect

Ingres org.hibernate.dialect.IngresDialect

Progress org.hibernate.dialect.ProgressDialect

Mckoi SQL org.hibernate.dialect.MckoiDialect

Interbase org.hibernate.dialect.InterbaseDialect

Pointbase org.hibernate.dialect.PointbaseDialect

FrontBase org.hibernate.dialect.FrontbaseDialect

Firebird org.hibernate.dialect.FirebirdDialect

参考文章:http://blog.csdn.net/qq_35447305/article/details/53327173

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值