我正在使用Spring Boot应用程序。我遇到了一些与 org.hibernate.HibernateException相关的问题:缺少列:medxlabpro.appsettings中的auth_password
我的PoJo班authpassword
中的列没有auth_password。那么为什么这类问题会出现在我的申请中。任何人都可以帮助我。我添加了JPA配置和Log。
根据我的担心,我猜它会因配置错误而来。
generate-ddl:false 冬眠: ddl-auto:验证
:: Spring Boot :: (v1.2.1.RELEASE)
2016-06-21 19:31:52.733 INFO 8196 --- [ main] org.sam.application.Application : Starting Application on DESKTOP-JIBLNR1 with PID 8196 (C:\LabSystem\Scheduler\target\classes started by Sitansu in C:\LabSystem\Scheduler)
2016-06-21 19:31:52.805 INFO 8196 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@bd4dc25: startup date [Tue Jun 21 19:31:52 IST 2016]; root of context hierarchy
2016-06-21 19:31:53.912 INFO 8196 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.scheduling.annotation.SchedulingConfiguration' of type [class org.springframework.scheduling.annotation.SchedulingConfiguration$$EnhancerBySpringCGLIB$$960de3bc] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-06-21 19:31:53.948 INFO 8196 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.scheduling.annotation.ProxyAsyncConfiguration' of type [class org.springframework.scheduling.annotation.ProxyAsyncConfiguration$$EnhancerBySpringCGLIB$$3cdcd8e2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-06-21 19:31:54.435 INFO 8196 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-06-21 19:31:54.463 INFO 8196 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2016-06-21 19:31:54.560 INFO 8196 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.7.Final}
2016-06-21 19:31:54.561 INFO 8196 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2016-06-21 19:31:54.563 INFO 8196 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2016-06-21 19:31:54.900 INFO 8196 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2016-06-21 19:31:55.677 INFO 8196 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2016-06-21 19:31:55.687 INFO 8196 --- [ main] o.h.e.jdbc.internal.LobCreatorBuilder : HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
2016-06-21 19:31:56.056 INFO 8196 --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2016-06-21 19:31:56.592 INFO 8196 --- [ main] o.h.tool.hbm2ddl.SchemaValidator : HHH000229: Running schema validator
2016-06-21 19:31:56.593 INFO 8196 --- [ main] o.h.tool.hbm2ddl.SchemaValidator : HHH000102: Fetching database metadata
2016-06-21 19:31:56.628 INFO 8196 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000261: Table found: medxlabpro.appsettings
2016-06-21 19:31:56.629 INFO 8196 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000037: Columns: [hl7ftphostname, hl7ftppassword, clientcode, desktopheight1, desktopheight2, newordereligipdfneeded, billingdays, receiptno, defaultpagesize, desktopheight3, postingbatchno, desktopheight4, desktopheight5, id, edibatchno, desktopheight6, datarootfolder, desktopheight7, desktopheight8, claimno, hl7ftpfolder, hl7ftpusername, neworderorderpdfneeded, authpassword, desktoppagesize8, hl7ftpport, desktoppagesize6, neworderresultpdfneeded, desktoppagesize7, desktoppagesize4, desktoppagesize5, versionno, desktoppagesize2, desktoppagesize3, desktoppagesize1, invoiceno]
2016-06-21 19:31:56.636 WARN 8196 --- [ main] s.c.a.AnnotationConfigApplicationContext : 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: Missing column: auth_password in abcdpro.appsettings
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
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:956)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at org.sam.application.Application.main(Application.java:33)
Caused by: org.hibernate.HibernateException: Missing column: auth_password in abcdpro.appsettings
at org.hibernate.mapping.Table.validateColumns(Table.java:365)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1338)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:525)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844)
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:1625)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
JPA配置:
jpa:
generate-ddl: false
hibernate:
ddl-auto: validate
database: MYSQL
show-sql: true
我怎么能解决这个问题,任何人都可以帮助我?
由于 Sitansu
答案 0 :(得分:1)
默认Spring Boot
使用SpringNamingStrategy。此策略在表和字段名称中生成下划线。因此,对于字段authPassword
,策略会生成auth_password
列名称。
如果要将实体字段映射到驼峰案例列名称,可以使用org.hibernate.cfg.EJB3NamingStrategy
或实现自己的名称。
您可以在application.properties
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
答案 1 :(得分:0)
我的PoJo类authpassword中的列没有auth_password。
简单的解决方案可能是:
将@Column(name="auth_password")
添加到您的authpassword
字段。
然后它应该工作