2016-05-04 7 views
0

名前の変更に問題があります。私のアプリケーションのコンテキストは、Jhipster製品の中で行われます(春ブート+春データjpa、休止状態4)。 @Column(name = "myColumnName")ですべてのデータベース列の名前を変更し、liquidbase xmlファイル内でテスト起動時にのみエラーが発生します。私がspring-boot:runでアプリケーションを起動すると、すべてうまくいきます。問題は、実行中の統合テストのみ(スプリングテストランナー付き)です。私はすべてのデータベース列を(以前はテストが順調に実行されていた)名前だけに変更したためです。ここでhibernate.hbm2ddl.auto set validateによって "missing column"例外が発生し、セッションの作成を妨げる

ロード春の文脈上のスタックトレース実行中のテストをしようとしたとき:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.core.userdetails.UserDetailsService com.tess2i.config.SecurityConfiguration.userDetailsService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.tess2i.repository.UserRepository com.tess2i.security.UserDetailsServiceImpl.userRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#8f062f' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#8f062f': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is 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 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1060) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.web.filter.DelegatingFilterProxy.initDelegate(DelegatingFilterProxy.java:326) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.web.filter.DelegatingFilterProxy.initFilterBean(DelegatingFilterProxy.java:235) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:199) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279) ~[tomcat-embed-core-8.0.30.jar:8.0.30] 
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:109) ~[tomcat-embed-core-8.0.30.jar:8.0.30] 
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4659) [tomcat-embed-core-8.0.30.jar:8.0.30] 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5281) [tomcat-embed-core-8.0.30.jar:8.0.30] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.0.30.jar:8.0.30] 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [tomcat-embed-core-8.0.30.jar:8.0.30] 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [tomcat-embed-core-8.0.30.jar:8.0.30] 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_72] 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_72] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_72] 
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_72] 

..... 

Caused by: org.hibernate.MappingException: Unable to find column with logical name: CONEBID in org.hibernate.mapping.Table(stfcoetb) and its related supertables and secondary tables 
    at org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:583) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final] 
    at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:258) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final] 
    at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:116) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final] 
    at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1598) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final] 
    at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1521) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final] 
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1422) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final] 
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final] 
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final] 
    ... 50 common frames omitted 

は、この起動時の問題を修正するには。私は単純に次の行を削除します: hibernate.hbm2ddl.auto:application.ymlファイル内で検証します(テストパッケージressourceのもの)。 私はメモリデータベースにH2を使用しているので、なぜこの設定ラインがデータベースカラムの名前変更に "干渉"するのか分かりません。私は解決策が嫌いです。これは私が思う問題の原因ではありません。列名の変更は、主にメモリデータベースにH2を使用する場合、「休止状態のチューニング」に依存してはなりません。

この問題の原因は何ですか? @Column(名前=「CONEBID」)

そして恐ろしい間違いがログメッセージで強調表示されていなかったという。

おかげ

+0

@Column(name = "myColumnName")を追加すると、hibernate.hbm2ddl.autoプロパティのcreate、create-dropまたはupdateを指定した場合にのみ何かが実行されます。このような場合、Hibernateは指定された名前に一致するカラムを持つテーブルを作成するか、既存のテーブルをマッピングに合わせて更新しようとします。 –

答えて

0

エラーがで空白によるものでした。 (唯一のテストのために)指定なし検証オプションがなかったので、それは実行時に働いていた

Caused by: org.hibernate.HibernateException: Missing column: 'conebid ' in TESSICOMMUNICATION.PUBLIC.STFCOETB 

Caused by: org.hibernate.HibernateException: Missing column: conebid in TESSICOMMUNICATION.PUBLIC.STFCOETB 

は、より良い出力を期待していました。そしてブランクはSQL(クエリ、カラム名)では無意味なので、クエリはうまく機能していました。 しかし、テストでは、JPA名と液体ベース生成hbmスキーマ名との間のマッピングを検証します。したがって、XMLとJavaは空白に敏感で、比較は正確です。

2時間の検索をいただきありがとうございます。立って!

関連する問題