我正在尝试在我的Spring Boot应用程序中使用弹性搜索。当我使用IDE(即Spring Boot应用程序的嵌入式tomcat服务器)运行该项目时,该项目运行良好。 当我尝试运行“ mvn clean install”将其打包以进行部署时,该版本会提示我
NoClassDefFoundError
例外
这是导致问题的堆栈跟踪
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticService' defined in file [/home/abiral/apps/elastic-project/target/classes/com/elastic/project/elasticproject/elastic/ElasticService.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.elastic.project.elasticproject.elastic.ElasticService]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/elasticsearch/script/ScriptEngine
我的Pom依赖项
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
</dependencies>
以前有人遇到过这个问题吗? 我用Google搜索,但找不到适合我的解决方案。 请给我建议解决方案。
mvn dependency:tree
[INFO] com.elastic.project:elastic-project:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter- web:jar:2.0.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.0.4.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:2.0.4.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.4.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.4.RELEASE:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.19:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.0.4.RELEASE:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.6:compile
[INFO] | | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.6:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.6:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.6:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.4.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.32:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.32:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.32:compile
[INFO] | +- org.hibernate.validator:hibernate-validator:jar:6.0.11.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] | +- org.springframework:spring-web:jar:5.0.8.RELEASE:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.0.8.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.0.8.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.0.8.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:5.0.8.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.0.8.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.0.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.4.RELEASE:compile
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:compile
[INFO] | | +- net.minidev:json-smart:jar:2.3:compile
[INFO] | | | \- net.minidev:accessors-smart:jar:1.2:compile
[INFO] | | | \- org.ow2.asm:asm:jar:5.0.4:compile
[INFO] | | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | +- junit:junit:jar:4.12:compile
[INFO] | +- org.assertj:assertj-core:jar:3.9.1:compile
[INFO] | +- org.mockito:mockito-core:jar:2.15.0:compile
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.7.11:compile
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.7.11:compile
[INFO] | | \- org.objenesis:objenesis:jar:2.6:compile
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:compile
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:compile
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:compile
[INFO] | +- org.springframework:spring-core:jar:5.0.8.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.0.8.RELEASE:compile
[INFO] | +- org.springframework:spring-test:jar:5.0.8.RELEASE:compile
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.5.1:compile
[INFO] +- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] +- org.elasticsearch.client:transport:jar:6.3.2:compile
[INFO] | +- org.elasticsearch:elasticsearch:jar:5.6.10:compile
[INFO] | | +- org.apache.lucene:lucene-core:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-analyzers-common:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-backward-codecs:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-grouping:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-highlighter:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-join:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-memory:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-misc:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-queries:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-queryparser:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-sandbox:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-spatial:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-spatial-extras:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-spatial3d:jar:6.6.1:compile
[INFO] | | +- org.apache.lucene:lucene-suggest:jar:6.6.1:compile
[INFO] | | +- org.elasticsearch:securesm:jar:1.2:compile
[INFO] | | +- net.sf.jopt-simple:jopt-simple:jar:5.0.2:compile
[INFO] | | +- com.carrotsearch:hppc:jar:0.7.1:compile
[INFO] | | +- joda-time:joda-time:jar:2.9.9:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-core:jar:2.9.6:compile
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.9.6:compile
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.9.6:compile
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.9.6:compile
[INFO] | | +- com.tdunning:t-digest:jar:3.0:compile
[INFO] | | +- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile
[INFO] | | +- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] | | \- org.elasticsearch:jna:jar:4.4.0-1:compile
[INFO] | +- org.elasticsearch.plugin:transport-netty4-client:jar:5.6.10:compile
[INFO] | | +- io.netty:netty-buffer:jar:4.1.27.Final:compile
[INFO] | | +- io.netty:netty-codec:jar:4.1.27.Final:compile
[INFO] | | +- io.netty:netty-codec-http:jar:4.1.27.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.27.Final:compile
[INFO] | | +- io.netty:netty-handler:jar:4.1.27.Final:compile
[INFO] | | +- io.netty:netty-resolver:jar:4.1.27.Final:compile
[INFO] | | +- io.netty:netty-transport:jar:4.1.27.Final:compile
[INFO] | | +- org.locationtech.spatial4j:spatial4j:jar:0.6:compile
[INFO] | | +- com.vividsolutions:jts:jar:1.13:compile
[INFO] | | \- org.apache.logging.log4j:log4j-core:jar:2.10.0:compile
[INFO] | +- org.elasticsearch.plugin:reindex-client:jar:6.3.2:compile
[INFO] | | \- org.elasticsearch.client:elasticsearch-rest-client:jar:6.3.2:compile
[INFO] | | +- org.apache.httpcomponents:httpclient:jar:4.5.6:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.4.10:compile
[INFO] | | +- org.apache.httpcomponents:httpasyncclient:jar:4.1.3:compile
[INFO] | | +- org.apache.httpcomponents:httpcore-nio:jar:4.4.10:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.11:compile
[INFO] | | \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] | +- org.elasticsearch.plugin:lang-mustache-client:jar:6.3.2:compile
[INFO] | | \- com.github.spullara.mustache.java:compiler:jar:0.9.3:compile
[INFO] | +- org.elasticsearch.plugin:percolator-client:jar:6.3.2:compile
[INFO] | +- org.elasticsearch.plugin:parent-join-client:jar:6.3.2:compile
[INFO] | \- org.elasticsearch.plugin:rank-eval-client:jar:6.3.2:compile
[INFO] \- org.springframework.boot:spring-boot-starter-data-elasticsearch:jar:2.0.4.RELEASE:compile
[INFO] \- org.springframework.data:spring-data-elasticsearch:jar:3.0.9.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:5.0.8.RELEASE:compile
[INFO] \- org.springframework.data:spring-data-commons:jar:2.0.9.RELEASE:compile