2015-11-04 43 views
5

我是Gradle的Spring Application中的新成員。 運行我的項目基礎上創建了類來創建數據庫對象,我得到了以下錯誤:無法解析名稱[org.hibernate.dialect.MySQL5Dialect]作爲策略[org.hibernate.dialect.Dialect]

Exception in thread "main" 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.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.dialect.MySQL5Dialect ] as strategy [org.hibernate.dialect.Dialect] 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1572) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) 
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:960) 
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:749) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) 
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:117) 
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:689) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:969) 
at org.springframework.boot.SpringApplication.run(SpringApplication.java:958) 
at com.krypton.smartImmo.SmartImmoApplication.main(SmartImmoApplication.java:10) 

Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.dialect.MySQL5Dialect ] as strategy [org.hibernate.dialect.Dialect] 
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:128) 
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveDefaultableStrategy(StrategySelectorImpl.java:155) 
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:136) 
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:78) 
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:68) 
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:165) 
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) 

application.properties我ahve有關以下設置休眠

spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy 

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect 
+0

哪個版本的Hibernate是你嗎? –

+0

@GergelyBacso version 4.3.11.Final – Djama

+0

我想你在「org.hibernate.dialect.MySQL5Dialect」後面加了一個空格....?我看到堆棧跟蹤中的空白「[org.hibernate.dialect.MySQL5Dialect]」 –

回答

26

由於你的錯誤消息在最後包含可疑的額外空間:

Unable to resolve name [org.hibernate.dialect.MySQL5Dialect ] 

I wi你會猜測你的方言屬性的末尾有一個額外的空間。

因此,尋找

"org.hibernate.dialect.MySQL5Dialect " 

並將其更改爲:

"org.hibernate.dialect.MySQL5Dialect" 
+0

是的,你是對的,不知道這可能是一個錯誤的根源:)。很高興得知 – Djama

+0

最常見的錯誤通常是使用未添加到特定休眠版本的方言,或者是大部分帶有大寫/小寫字母錯誤的有趣拼寫錯誤。 –

相關問題