Description: An issue about spring boot with swagger2 integration through spring-fox library. BeanCreationException: Error creating bean with name 'cachingOperationNameGenerator' defined in URL.
Tried to integrated swagger2 into current java project. Flowing [instructions], when the application start, NoSuchMethodError occurred. Did quite a lot of search on google, no related result.
The project is maven based with multiple language integrate including java, scala and kotlin.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cachingOperationNameGenerator' defined in URL [jar:file:/C:/Users/xcwhung/.m2/repository/io/springfox/springfox-spring-web/2.9.2/springfox-spring-web-2.9.2.jar!/springfox/documentation/spring/web/readers/operation/CachingOperationNameGenerator.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.google.common.collect.Maps.newHashMap()Ljava/util/HashMap;
.
.
.
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.google.common.collect.Maps.newHashMap()Ljava/util/HashMap;
.
.
.
Caused by: java.lang.NoSuchMethodError: com.google.common.collect.Maps.newHashMap()Ljava/util/HashMap;
.
.
.
... 24 more
Tried to include the dependency of maven guava, but not working.
Finally found the issue caused by the dependency of kotlin-compiler (1.3.x) in the maven plugin. The dependency embedded the guava library and the class com.google.common.collect.Maps was from kotlin-compiler.jar instead of guava dependency.
One the solution i used to overcome is down grade the kotlin-compiler dependency to 1.2.71 explicitly.
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-compiler</artifactId>
<version>1.2.71</version>
</dependency>
[[Legacy Link]]https://xeth0102.atlassian.net/wiki/spaces/DW/blog/2019/09/05/253132831