0

I can't start my Spring Boot application anymore after adding persistence. The error is:

java.lang.NoSuchMethodError: org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;Lorg/springframework/beans/factory/support/BeanDefinitionRegistry;)V
at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$1.<init>(AbstractRepositoryConfigurationSourceSupport.java:68) ~[spring-boot-autoconfigure-1.5.7.RELEASE.jar:1.5.7.RELEASE]

I tracked this down to the changes in spring-data-commons where AnnotationRepositoryConfigurationSource resides and an additional constructor argument was added in version 1.13.5, and version 1.13.7 with the same constructor signature should be used by spring-boot-starter-data-jpa in version 1.5.7. And we only use Spring Boot dependencies with version number 1.5.7.

So then I built the dependency tree and strangely found spring-data-commons in version 1.13.4, not 1.13.7 (third to last line):

...(snippet)
[INFO] +- com.name.project:project-subproject8:jar:1.0.0-SNAPSHOT:compile
[INFO] |  \- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.7.RELEASE:compile
[INFO] |     +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.4.RELEASE:compile
[INFO] |     |  +- org.apache.tomcat:tomcat-jdbc:jar:8.5.15:compile
[INFO] |     |  |  \- org.apache.tomcat:tomcat-juli:jar:8.5.15:compile
[INFO] |     |  \- org.springframework:spring-jdbc:jar:4.3.9.RELEASE:compile
[INFO] |     +- org.hibernate:hibernate-core:jar:5.0.12.Final:compile
[INFO] |     |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |     |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |     |  +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] |     |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |     |  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] |     +- org.hibernate:hibernate-entitymanager:jar:5.0.12.Final:compile
[INFO] |     +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] |     +- org.springframework.data:spring-data-jpa:jar:1.11.4.RELEASE:compile
[INFO] |     |  +- org.springframework.data:spring-data-commons:jar:1.13.4.RELEASE:compile
[INFO] |     |  \- org.springframework:spring-orm:jar:4.3.9.RELEASE:compile
[INFO] |     \- org.springframework:spring-aspects:jar:4.3.9.RELEASE:compile
...

Going up the tree you can see that spring-data-jpa is included in version 1.11.4, whereas, according to Spring Boot Dependency Appendix, it should be version 1.11.7. This seems to cause the error. But we don't depend on spring-data-jpa directly via our pom files.

So I don't know how this older version got into the dependency tree. The pom of spring-boot-starter-data-jpa doesn't indicate any version numbers.

JustCode
  • 89
  • 2
  • 6

1 Answers1

0

I had the same issue, and yeah it is SOLVED now!!! You can always exclude particular inner dependency from the outer dependency. You have already given hint to solve this issue. The root cause is that you most likely have compiled a class against a different version of the class that is missing a method, than the one you are using when running it. I switched to 1.5.7 version of spring boot, so i just needed to add jpa dependency compatible with spring boot 1.5.7 version. Why jpa dependency because - org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource is in the spring data package. And it worked

Kusum
  • 241
  • 5
  • 20