我收到NoSuchMethodError
,错误是:
Caused by: java.lang.NoSuchMethodError: com.google.common.cache.CacheBuilder.maximumSize(J)Lcom/google/common/cache/CacheBuilder;
at springfox.documentation.spring.web.scanners.CachingOperationReader.<init>(CachingOperationReader.java:44) ~[springfox-spring-web-2.7.0.jar:2.7.0]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_172]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_172]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_172]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_172]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:170) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
... 60 common frames omitted
我认为出错的原因是因为CacheBuilder在两个jar中可用。我正在用流口水和大摇大摆来制作弹簧靴产品。我的依存关系列表包含以下依存关系
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>${kie.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
现在kie-ci
有sisu-guava
和swagger
有guava
jar,我通过运行
mvn dependency:tree -Dverbose | grep guava
$ mvn dependency:tree -Dverbose | grep guava
[INFO] | | | \- org.sonatype.sisu:sisu-guava:jar:0.9.9:compile
[INFO] +- com.google.guava:guava:jar:18.0:compile
依赖性树的输出为
$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building pricing 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) @ pricing ---
[INFO] com.wf:pricing:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-aop: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-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.apache.logging.log4j:log4j-api: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:runtime
[INFO] | +- org.springframework:spring-aop:jar:5.0.8.RELEASE:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.0.8.RELEASE:compile
[INFO] | \- org.aspectj:aspectjweaver:jar:1.8.13:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-rest:jar:2.0.4.RELEASE: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-core:jar:2.9.6: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.data:spring-data-rest-webmvc:jar:3.0.9.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-rest-core:jar:3.0.9.RELEASE:compile
[INFO] | | +- org.springframework:spring-tx:jar:5.0.8.RELEASE:compile
[INFO] | | +- org.springframework.hateoas:spring-hateoas:jar:0.25.0.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:2.0.9.RELEASE:compile
[INFO] | | \- org.atteo:evo-inflector:jar:1.2.2:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.0.4.RELEASE: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] | +- org.springframework:spring-web:jar:5.0.8.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc: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-devtools:jar:2.0.4.RELEASE:runtime
[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] +- com.h2database:h2:jar:1.4.197:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.4.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.0.4.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.4.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.3:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.2:test
[INFO] | | \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | +- org.assertj:assertj-core:jar:3.9.1:test
[INFO] | +- org.mockito:mockito-core:jar:2.15.0:test
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.7.11:compile
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.7.11:test
[INFO] | | \- org.objenesis:objenesis:jar:2.6:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[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:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.5.1:test
[INFO] +- org.kie:kie-ci:jar:6.1.0.Final:compile
[INFO] | +- org.drools:drools-core:jar:6.1.0.Final:compile
[INFO] | | +- org.mvel:mvel2:jar:2.2.1.Final:compile
[INFO] | | +- org.kie:kie-api:jar:6.1.0.Final:compile
[INFO] | | \- org.kie:kie-internal:jar:6.1.0.Final:compile
[INFO] | +- org.drools:drools-compiler:jar:6.1.0.Final:compile
[INFO] | | +- org.antlr:antlr-runtime:jar:3.5:compile
[INFO] | | +- org.eclipse.jdt.core.compiler:ecj:jar:4.3.1:compile
[INFO] | | +- com.thoughtworks.xstream:xstream:jar:1.4.7:compile
[INFO] | | | +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] | | | \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] | | \- com.google.protobuf:protobuf-java:jar:2.5.0:compile
[INFO] | +- org.apache.maven:maven-core:jar:3.0.5:compile
[INFO] | | +- org.apache.maven:maven-settings:jar:3.0.5:compile
[INFO] | | +- org.apache.maven:maven-settings-builder:jar:3.0.5:compile
[INFO] | | +- org.apache.maven:maven-repository-metadata:jar:3.0.5:compile
[INFO] | | +- org.apache.maven:maven-artifact:jar:3.0.5:compile
[INFO] | | +- org.apache.maven:maven-plugin-api:jar:3.0.5:compile
[INFO] | | +- org.apache.maven:maven-model-builder:jar:3.0.5:compile
[INFO] | | +- org.apache.maven:maven-aether-provider:jar:3.0.5:compile
[INFO] | | +- org.sonatype.sisu:sisu-inject-plexus:jar:2.3.0:compile
[INFO] | | | \- org.sonatype.sisu:sisu-inject-bean:jar:2.3.0:compile
[INFO] | | | \- org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0:compile
[INFO] | | | \- org.sonatype.sisu:sisu-guava:jar:0.9.9:compile
[INFO] | | +- org.codehaus.plexus:plexus-interpolation:jar:1.14:compile
[INFO] | | +- org.codehaus.plexus:plexus-utils:jar:2.0.6:compile
[INFO] | | +- org.codehaus.plexus:plexus-classworlds:jar:2.4:compile
[INFO] | | +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile
[INFO] | | \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[INFO] | | \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] | +- org.apache.maven:maven-model:jar:3.0.5:compile
[INFO] | +- org.apache.maven:maven-compat:jar:3.0.5:compile
[INFO] | | \- org.apache.maven.wagon:wagon-provider-api:jar:2.4:compile
[INFO] | +- org.sonatype.aether:aether-api:jar:1.13.1:compile
[INFO] | +- org.sonatype.aether:aether-util:jar:1.13.1:compile
[INFO] | +- org.sonatype.aether:aether-impl:jar:1.13.1:compile
[INFO] | | \- org.sonatype.aether:aether-spi:jar:1.13.1:compile
[INFO] | +- org.sonatype.aether:aether-connector-wagon:jar:1.13.1:compile
[INFO] | +- org.sonatype.aether:aether-connector-file:jar:1.13.1:compile
[INFO] | +- org.apache.ant:ant:jar:1.8.2:compile
[INFO] | | \- org.apache.ant:ant-launcher:jar:1.8.2:compile
[INFO] | +- org.apache.maven.wagon:wagon-http:jar:2.0:compile
[INFO] | | +- org.apache.maven.wagon:wagon-http-shared4:jar:2.0:compile
[INFO] | | | +- org.jsoup:jsoup:jar:1.6.1:compile
[INFO] | | | +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | | | \- commons-io:commons-io:jar:2.0.1:compile
[INFO] | | \- org.apache.httpcomponents:httpclient:jar:4.5.6:compile
[INFO] | | \- commons-codec:commons-codec:jar:1.11:compile
[INFO] | \- org.apache.httpcomponents:httpcore:jar:4.4.10:compile
[INFO] \- io.springfox:springfox-swagger2:jar:2.7.0:compile
[INFO] +- io.swagger:swagger-annotations:jar:1.5.13:compile
[INFO] +- io.swagger:swagger-models:jar:1.5.13:compile
[INFO] +- io.springfox:springfox-spi:jar:2.7.0:compile
[INFO] | \- io.springfox:springfox-core:jar:2.7.0:compile
[INFO] +- io.springfox:springfox-schema:jar:2.7.0:compile
[INFO] +- io.springfox:springfox-swagger-common:jar:2.7.0:compile
[INFO] +- io.springfox:springfox-spring-web:jar:2.7.0:compile
[INFO] | \- org.reflections:reflections:jar:0.9.11:compile
[INFO] | \- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] +- com.google.guava:guava:jar:18.0:compile
[INFO] +- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] \- org.mapstruct:mapstruct:jar:1.1.0.Final:compile
任何建议我需要排除哪个罐子。
答案 0 :(得分:0)
我遇到了一个非常相似的问题,我通过将我需要的依赖项放在 pom 中来解决它,并确保将它放在你不需要的那个之前。例如您实际上需要com.google.guava:guava
而不是org.sonatype.sisu:sisu-guava
,然后将com.google.guava:guava
放入pom中,并确保它位于com.google.guava:guava
的父包之前。