我正在尝试创建此course中使用的基于gradle的treehouse 'unit-testing-a-spring-application‘项目的maven版本。请参阅课程代码here。
在最初无法构建之后,我最终添加了在原始gradle构建文件中指定的依赖项版本。Maven可以很好地构建,但运行应用程序会得到以下结果:
The following method did not exist:
org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)
Ljava/lang/String;
The method's class, org.springframework.data.repository.config.RepositoryConfigurationSource, is
available from the following locations:
jar:file:/C:/Users/home/.m2/repository/org/springframework/data/spring-data-
commons/2.1.6.RELEASE/spring-data-commons-2.1.6.RELEASE.jar!/org/springframework/data/repository/config/RepositoryConfigurationSource.class
It was loaded from the following location:
file:/C:/Users/home/.m2/repository/org/springframework/data/spring-data-commons/2.1.6.RELEASE/spring-
data-commons-2.1.6.RELEASE.jar
Action
Correct the classpath of your application so that it contains a single, compatible version of
org.springframework.data.repository.config.RepositoryConfigurationSource.通过更改一些相关依赖项的版本,在S.O.上解决了几个类似的问题。我已经尝试了以下的各种版本,但都没有用(我通常坚持使用spring-boot-starter-parent v2.1.4,因为它一直适用于我的项目):
spring-data-commons
spring-boot-starter-parent我在我的项目依赖项目录中看到下面列出了所需的类,但是在这种情况下,哪些依赖项版本可以工作?否则我怎么能解决这个问题呢?
org/springframework/data/repository/config/RepositoryConfigurationSource.class发布于 2020-07-24 04:05:27
我看了你的代码,发现了一些错误。由于您的项目是一个spring-boot项目,所以您不能在pom文件中添加直接的spring依赖项。相反,尝试使用基于spring-boot的依赖项。例如,不是这样的依赖关系:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.9.2.RELEASE</version>
</dependency>您的pom文件中必须包含以下内容。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>https://stackoverflow.com/questions/63061640
复制相似问题