2016-11-25 25 views
0

私はGradleを使用しています(Spring Boot 1.4.2、Thymeleaf、Elasticsearch 2.3.4)。私はローカルで作業しています。 thymeleaf-extras-springsecurity4モジュールを使用してThymeleafセキュリティを実装しようとしていますが、問題が発生しました。バンドルのロードに失敗しました

私はこのエラーを得た:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDashboardDaoImpl': Unsatisfied dependency expressed through field 'userDashboardRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDashboardRepository': Cannot resolve reference to bean 'elasticsearchTemplate' while setting bean property 'elasticsearchOperations'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'elasticsearchTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'elasticsearchTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticsearchClient' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.Client]: Factory method 'elasticsearchClient' threw exception; nested exception is java.lang.IllegalStateException: java.lang.IllegalStateException: failed to load bundle [file:/D:/elasticsearch-2.3.4/modules/lang-expression/antlr4-runtime-4.5.1-1.jar, file:/D:/elasticsearch-2.3.4/modules/lang-expression/asm-5.0.4.jar, file:/D:/elasticsearch-2.3.4/modules/lang-expression/asm-commons-5.0.4.jar, file:/D:/elasticsearch-2.3.4/modules/lang-expression/lang-expression-2.3.4.jar, file:/D:/elasticsearch-2.3.4/modules/lang-expression/lucene-expressions-5.5.0.jar] due to jar hell 

build.gradleは次のとおりです。

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin: 1.4.2.RELEASE") 
    } 
} 
apply plugin: 'java' 
apply plugin: 'org.springframework.boot' 
jar { 
    baseName = 'Selva' 
    version = '0.1.0' 
} 
sourceCompatibility = 1.8 
targetCompatibility = 1.8 
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' 
dependencyManagement { 
    imports { 
     mavenBom 'org.springframework.boot:spring-boot-starter-parent:1.4.2.RELEASE' 
    } 
} 
if (!hasProperty('mainClass')) { 
    ext.mainClass = '*.*.config.Application' 
} 
configurations { 
     provided 
} 
repositories { 
     mavenCentral() 
     maven { 
     url "http://jasperreports.sourceforge.net/maven2" 
     } 
     maven { 
     url "http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/" 
     } 
    } 
    dependencies { 
    compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: '1.4.2.RELEASE' 
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '1.4.2.RELEASE' 
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.4.2.RELEASE' 
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-elasticsearch', version: '1.4.2.RELEASE' 
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.4.2.RELEASE' 
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf', version: '1.4.2.RELEASE' 
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '1.4.2.RELEASE' 
compile group: 'com.h2database', name: 'h2', version: '1.4.193' 
compile group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect', version: '2.1.1' 
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '3.0.1.RELEASE' 
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0' 
} 

答えて

0

これが原因JAR地獄です。

org.springframework.boot:spring-boot-starter-data-elasticsearch:1.4.0.RELEASE'に依存しています。org.springframework.data:spring-data-elasticsearchをインポートし、org.elasticsearch:elasticsearchをインポートします。

org.elasticsearch:elasticsearch:2.3.4を直接インポートすると、2つのelasticsearch JAR、つまりJAR地獄になります。

spring-boot-starter-data-elasticsearchを使用している場合は、org.elasticsearch:elasticsearchにインポートする必要はありません。

これを削除すれば問題ありません。

+0

これをテストできましたか? – Val

関連する問題