解决 Springboot Unable to build Hibernate SessionFactory @Column命名不起作用
2017-01-05 17:15
453 查看
问题:
Springboot启动报错:Caused by: 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 javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
Springboot 版本 1.4.3.RELEASE
Hibernate相关属性:
spring.jpa.hibernate.ddl-auto=validate
解决:
配置application.properties为spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
过程:
配置debug=true spring.jpa.show-sql=true
日志提示@Column(name)的注解与数据库字段不匹配。发现问题。
原因:
Springboot的JPA由Hibernate实现。Springboot中默认配置的物理命名策略naming.physical-strategy为org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy。把Identifier name用toUnderScoreCase下划线命名规则又转换一次…真是反直觉……一般大公司都会对常用组件基于开源项目自己去做一套框架去使用,并不能完全发挥Springboot“无配置”整合第三方框架的优点,踩到的坑会比传统Spring深一点…
相关文章推荐
- jpa整合spring和springData出错: Unable to build Hibernate SessionFactory
- JPA报错, PersistenceException_Unable to build Hibernate SessionFactory
- spring注解空指针异常 'sessionFactory' or 'hibernateTemplate' is required的解决方法
- Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFac
- spring boot打包时Unable to find a single main class的解决方法
- Spring-boot Unable to start EmbeddedWebApplicationContext 分析与解决方法
- Spring JUnit org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- Spring Boot错误:Unable to start embedded container...的问题解决
- springboot,hibernate,exception no session 问题解决
- 最近用STS搭建hibernate&spring,遇到Could not locate SessionFactory in JNDI.找到这个文章很快解决了
- spring整合hibernate出现HibernateException: Unable to get the default Bean Validation factory
- Spring注解方式,异常 'sessionFactory' or 'hibernateTemplate' is required的解决方法 转载的
- 异常解决—org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- %%%% Error Creating SessionFactory %%%% org.hibernate.InvalidMappingException: Unable to read XML
- hibernate和spring整合:Unable to get the default Bean Validation factory
- Hibernate错误:Unable to build the default Bean Validator Factory
- springboot junit启动报错:HV000183: Unable to initialize 'javax.el.ExpressionFactory'.
- Maven使用package打包Spring Boot时出现:Unable to find a single main class from the following candidates的问题解决
- spring整合hibernate出现HibernateException: Unable to get the default Bean Validation factory
- Initial SessionFactory creation failed.org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.t