我正在使用CRUDRepository来使用JPA执行crud操作,但是我收到了这个错误:
java.lang.NoSuchMethodError: org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension.registerIfNotAlreadyRegistered
请帮忙。
答案 0 :(得分:4)
它来自这个提交:
所以你至少需要spring-data-commons 1.10.0.RELEASE:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.10.0.RELEASE</version>
</dependency>
但是:如果发生这种情况可能是因为您之间存在版本之间的冲突,那么如果您发现为什么要加载较旧的spring-data-commons会更好
答案 1 :(得分:0)
我能够解决这个错误,早些时候我正在使用spring-data-jpa.1.7.2.RELEASE.jar,现在我切换到spring-data-jpa.1.6.0.RELEASE.jar并解决了问题
感谢您的帮助。
答案 2 :(得分:0)
当你的maven pom.xml文件中有两个具有相同“groupId”但版本不同的依赖项时,通常会发生这种情况。
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-commons-core -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons-core</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.11.1.RELEASE</version>
</dependency>
Common“groupId”应具有相同的版本号。