溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

如何解決springboot啟動(dòng)失敗的問題

發(fā)布時(shí)間:2021-12-29 12:41:40 來源:億速云 閱讀:223 作者:小新 欄目:開發(fā)技術(shù)

這篇文章主要介紹如何解決springboot啟動(dòng)失敗的問題,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

    springboot啟動(dòng)失敗的問題

    springboot版本是1.3.0.M1,連接的mysql版本為8,用spring-boot-starter-data-jpa操做數(shù)據(jù)庫

    啟動(dòng)springboot報(bào)錯(cuò)如下

    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 be null 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 be null 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

    這一句比較關(guān)鍵:

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

    原來是Hibernate SQL方言沒有設(shè)置導(dǎo)致的,在properties文件中增加下面這行:

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

    再啟動(dòng)springboot,這次啟動(dòng)成功了;

    將Hibernate SQL方言整理如下表

    數(shù)據(jù)庫方言
    DB2org.hibernate.dialect.DB2Dialect
    DB2 AS/400org.hibernate.dialect.DB2400Dialect
    DB2 OS390org.hibernate.dialect.DB2390Dialect
    PostgreSQLorg.hibernate.dialect.PostgreSQLDialect
    MySQLorg.hibernate.dialect.MySQLDialect
    MySQL with InnoDBorg.hibernate.dialect.MySQLInnoDBDialect
    MySQL with MyISAMorg.hibernate.dialect.MySQLMyISAMDialect
    Oracle (any version)org.hibernate.dialect.OracleDialect
    Oracle 9i/10gorg.hibernate.dialect.Oracle9Dialect
    Sybaseorg.hibernate.dialect.SybaseDialect
    Sybase Anywhereorg.hibernate.dialect.SybaseAnywhereDialect
    Microsoft SQL Serverorg.hibernate.dialect.SQLServerDialect
    SAP DBorg.hibernate.dialect.SAPDBDialect
    Informixorg.hibernate.dialect.InformixDialect
    HypersonicSQLorg.hibernate.dialect.HSQLDialect
    Ingresorg.hibernate.dialect.IngresDialect
    Progressorg.hibernate.dialect.ProgressDialect
    Mckoi SQLorg.hibernate.dialect.MckoiDialect
    Interbaseorg.hibernate.dialect.InterbaseDialect
    Pointbaseorg.hibernate.dialect.PointbaseDialect
    FrontBaseorg.hibernate.dialect.FrontbaseDialect
    Firebirdorg.hibernate.dialect.FirebirdDialect

    springboot出現(xiàn)'hibernate.dialect'not set

    在application.properties內(nèi)寫下這兩條

    雙保險(xiǎn)!

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

    以上是“如何解決springboot啟動(dòng)失敗的問題”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

    向AI問一下細(xì)節(jié)

    免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

    AI