2017-10-19 21 views
1

Spring起動アプリケーションで起動時にこの問題が発生しました。Springブート+ Hibernate検索:entityManagerFactory依存性エラー

結果がこれです:

WARN 8532 --- [ main] o.h.s.a.i.LuceneEmbeddedAnalyzerStrategy : HSEARCH000075: Configuration setting hibernate.search.lucene_version was not specified: using LUCENE_CURRENT. WARN 8532 --- [ 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 java.lang.NoSuchMethodError: > org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Properties; INFO 8532 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] INFO 8532 --- [ main] utoConfigurationReportLoggingInitializer :

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. ERROR 8532 --- [ main] o.s.boot.SpringApplication : Application startup failed

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 java.lang.NoSuchMethodError:org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Properties; at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078) ~[spring-context-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.4.RELEASE.jar!/:1.5.4.RELEASE] at com.closdeal.restService.RestServiceApplication.main(RestServiceApplication.java:20) [classes!/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [closdeal-rest-service-1.0.2.jar:na] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [closdeal-rest-service-1.0.2.jar:na] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [closdeal-rest-service-1.0.2.jar:na] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [closdeal-rest-service-1.0.2.jar:na] Caused by: java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Properties; at org.hibernate.jpa.internal.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:124) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:890) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370) ~[spring-orm-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359) ~[spring-orm-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.9.RELEASE.jar!/:4.3.9.RELEASE] ... 24 common frames omitted

これらはbuild.gradle内で宣言依存関係です:

私は休止状態に(のEntityManagerFactoryクラスのgetPropertiesメソッドのシグネチャをチェックした
dependencies { 
    //Spring 
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.7.RELEASE' 
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-rest', version: '1.5.7.RELEASE' 
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '1.5.7.RELEASE' 
    compile group: 'org.springframework.security', name: 'spring-security-data', version: '4.2.3.RELEASE' 
    compile group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: '2.1.1.RELEASE' 
    compile group: 'org.springframework.data', name: 'spring-data-rest-hal-browser', version: '3.0.0.RELEASE' 

    //Hibernate 
    compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.11.Final' 
    compile group: 'org.hibernate', name: 'hibernate-spatial', version: '5.2.11.Final' 
    compile group: 'org.hibernate', name: 'hibernate-search-orm', version: '5.8.1.Final' 
// compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Final' 

    //JSON 
    compile("org.codehaus.jackson:jackson-mapper-asl") 

    //Bases de datos 
    compile("com.h2database:h2") 
    compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.7-dmr' 

    //Utilerías varias 
    compile group: 'commons-io', name: 'commons-io', version: '2.5' 
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.6' 
    compile group: 'org.apache.commons', name: 'commons-text', version: '1.1' 
    compile group: 'commons-codec', name: 'commons-codec', version: '1.10' 
    compile group: 'commons-validator', name: 'commons-validator', version: '1.6' 
    compile group: 'net.glxn', name: 'qrgen', version: '1.4' 
    compile group: 'com.vividsolutions', name: 'jts', version: '1.13' 


    //Test 
    testCompile("org.junit.jupiter:junit-jupiter-api:5.0.0") 
    testRuntime("org.junit.jupiter:junit-jupiter-engine:5.0.0") 
    testCompile("org.junit.platform:junit-platform-runner:1.0.0") 

    testCompile('org.springframework.boot:spring-boot-starter-test') 
} 

-jpa-2.1-api-1.0.0.Final.jar)はこれです:

public Map<String, Object> getProperties(); 

私は知らないこのメソッドは、マップではなくPropertiesオブジェクトを返すことを想定しています。この瓶はかなり古いです(2013年以降は変わりません)。 EntityManagerFactoryクラスをクラスパスに宣言する他のjarファイルは存在しないようです。私はこれに似た他の質問をチェックしましたが、クラスパスのこのクラスの複製をクラスパスに指していますが、ここでは問題ではないようです。

ありがとうございます。

- UPDATE:

dependencyManagement { 
    imports { 
     mavenBom 'org.springframework.boot:spring-boot-dependencies:1.5.8.RELEASE' 
    } 
} 

dependencies { 
    //Spring 
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web' 
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-rest' 
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa' 
    compile group: 'org.springframework.security', name: 'spring-security-data' 
    compile group: 'org.springframework.security.oauth', name: 'spring-security-oauth2' 
    compile group: 'org.springframework.data', name: 'spring-data-rest-hal-browser' 

    //Hibernate 
    compile group: 'org.hibernate', name: 'hibernate-core', version: '5.1.10.Final' 
    compile group: 'org.hibernate', name: 'hibernate-spatial', version: '5.1.10.Final' 
    compile group: 'org.hibernate', name: 'hibernate-search', version: '5.6.3.Final' 
    compile group: 'org.hibernate', name: 'hibernate-search-engine', version: '5.6.3.Final' 
    compile group: 'org.hibernate', name: 'hibernate-search-orm', version: '5.6.3.Final' 

    //JSON 
    compile("org.codehaus.jackson:jackson-mapper-asl") 

    //Bases de datos 
    compile("com.h2database:h2") 
    compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.7-dmr' 

    //Utilerías varias 
    compile group: 'commons-io', name: 'commons-io', version: '2.5' 
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.6' 
    compile group: 'org.apache.commons', name: 'commons-text', version: '1.1' 
    compile group: 'commons-codec', name: 'commons-codec', version: '1.10' 
    compile group: 'commons-validator', name: 'commons-validator', version: '1.6' 
    compile group: 'net.glxn', name: 'qrgen', version: '1.4' 
    compile group: 'com.vividsolutions', name: 'jts', version: '1.13' 


    //Test 
    testCompile("org.junit.jupiter:junit-jupiter-api:5.0.0") 
    testRuntime("org.junit.jupiter:junit-jupiter-engine:5.0.0") 
    testCompile("org.junit.platform:junit-platform-runner:1.0.0") 

    testCompile('org.springframework.boot:spring-boot-starter-test') 
} 

正しく動作するようです:私はGradleの依存関係dependencyManagementセクションを追加し、ギョームの提案に応じて依存関係の編集を変更しました。私はそれを確認し、後でそれを確認します。

答えて

2

AFAICS Spring Bootは依然としてHibernate ORM 5.0.xに基づいています。 https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/1.5.7.RELEASE/spring-boot-dependencies-1.5.7.RELEASE.pomを参照してください。

これは、このエラーが発生した理由を説明しています。

Hibernate ORM 5.1でも動作するかもしれませんが、5.2では多くの変更があります。

したがって、ORMを最新の5.0.xまたは5.1.xにダウングレードする必要があります(自己責任で)。また、Hibernate Searchを最新の5.6.xにダウングレードする必要があります。

+0

を私が...これに – Serginho

+0

ギヨームを試してみるよ、その問題のようです!私があなたの提案に基づいて何を説明したかという主な質問を調べてください。 ありがとうございました! – Serginho

0

Springブート1.5は、Hibernate ORM 5.2/search 5.8で動作しますが、すべての依存関係をオーバーライドする必要があります。私はあなたがオリジナルの設定でいくつかのものをオーバーロードしていると思うし、クラスパスにHibernate ORMの複数のバージョンがあると思われます。

Gradleで行う方法はわかりませんが、Mavenではhibernate.versionプロパティをオーバーライドする必要があります。ここで

は、Mavenを持つ例である場合に役立ちます、:

https://github.com/hibernate/hibernate-demos/blob/master/hibernate-search/hsearch-elasticsearch-wikipedia/pom.xml#L28

関連する問題