Spring Boot拒绝启动,与AbstractRepositoryConfigurationSourceSupport有问题。

huangapple go评论80阅读模式
英文:

Spring Boot Refuses to Start, problem with AbstractRepositoryConfigurationSourceSupport

问题

我使用Spring Starter创建了一个项目,但无法运行。它给了我一个错误消息,看起来像是这样的:

说明:

尝试调用一个不存在的方法。尝试是从以下位置进行的:

    org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$AutoConfiguredAnnotationRepositoryConfigurationSource.<init>(AbstractRepositoryConfigurationSourceSupport.java:133)

以下方法不存在:

    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;Lorg/springframework/beans/factory/support/BeanNameGenerator;)V

方法的类 org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource 可在以下位置找到:

    jar:file:/Users/miguelmunoz/.m2/repository/org/springframework/data/spring-data-commons/1.13.10.RELEASE/spring-data-commons-1.13.10.RELEASE.jar!/org/springframework/data/repository/config/AnnotationRepositoryConfigurationSource.class

类层次结构从以下位置加载:

    org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource: file:/Users/miguelmunoz/.m2/repository/org/springframework/data/spring-data-commons/1.13.10.RELEASE/spring-data-commons-1.13.10.RELEASE.jar
    org.springframework.data.repository.config.RepositoryConfigurationSourceSupport: file:/Users/miguelmunoz/.m2/repository/org/springframework/data/spring-data-commons/1.13.10.RELEASE/spring-data-commons-1.13.10.RELEASE.jar


操作:

修正应用程序的类路径,使其包含一个兼容版本的 org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource

我不知道如何修复这个问题。我在 https://github.com/SwingGuy1024/dummy.artifact-MRTC 上创建了一个最小可复现的测试案例。

我的 pom 文件如下:

<project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
        http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>dummy</groupId>
    <artifactId>dummy.artifact</artifactId>
    <packaging>jar</packaging>
    <name>dummy.artifact</name>
    <version>1.0</version>
    <properties>
        <java.version>1.8</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <springfox-version>2.9.2</springfox-version>
    </properties>
    <!-- 省略剩余部分 -->

补充: 据我所知,我只有一个 AnnotationRepositoryConfigurationSource 类的版本,它在 spring-data-commons 存储库中。据我理解,spring-data 的版本应该由我的 pom.xml 文件中的 dependencyManagement 部分确定,我在其中指定了 spring-data-releasetrain。我尝试了多种不同的值,但它们都不起作用。这里指定的 Neumann-SR4 是最新的一个。但它没有给我最新版本的 spring-data-commons。

补充2: 根据 gtiwari333 的建议进行的更改

我进行了以下更改,并将它们提交到了 GitHub 存储库。但我仍然有问题。

  1. 我将类 RFC3339DateFormat 和 Swagger2SpringBoot 移动到 dummy 包,并调整了 @ComponentScan 注解的参数。
  2. 我将 CTwo 重命名为 CTwoDto,并在新的 dummy.entity 包中创建了一个新的 CTwo 类。
  3. 存储库现在使用新的 CTwo 实体类。
  4. 我将 Spring Boot 版本升级到了 2.3.3.RELEASE。(2.3.4 在一个由 Swagger 生成的文件中给我一个编译错误 — 无法找到 javax.servlet.http.HttpServletRequest
  5. 我删除了三个依赖项:jackson-datatype-jsr310validation-apijackson-annotations
  6. 我从 pom 文件中删除了 dependencyManagement 部分。
  7. 我调整了日志记录级别。

(这些更改将我带回了最初导致我创建此 MRTC 的错误。)

我仍然收到一个错误消息,尽管是另一条错误消息。

说明:

尝试调用一个不存在的方法。尝试是从以下位置进行的:

    org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(AnnotationRepositoryConfigurationSource.java:126)

以下方法不存在:

    org.springframework.core.type.AnnotationMetadata.introspect(Ljava/lang/Class;)Lorg/springframework/core/type/AnnotationMetadata;

方法的类 org.springframework.core.type.AnnotationMetadata 可在以下位置找到:

    jar:file:/Users/miguelmunoz/.m2/repository/org/springframework/spring-core/5.1.9.RELEASE/spring-core-5.1.9.RELEASE.jar!/org/springframework/core/type/AnnotationMetadata.class

它是从以下位置加载的:

    file:/Users/miguelmunoz/.m2/repository/org/springframework/spring-core/5.1.9.RELEASE/spring-core-5.1.9.RELEASE.jar


操作:

修正应用程序的类路径,使其包含一个兼容版本的 org.springframework.core.type.AnnotationMetadata

再次强调,我只有一个关于这个问题的类版本。

英文:

I created a project using the Spring Starter, but it won't run. It gives me an error message that looks like this:

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$AutoConfiguredAnnotationRepositoryConfigurationSource.&lt;init&gt;(AbstractRepositoryConfigurationSourceSupport.java:133)

The following method did not exist:

    org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.&lt;init&gt;(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;Lorg/springframework/beans/factory/support/BeanDefinitionRegistry;Lorg/springframework/beans/factory/support/BeanNameGenerator;)V

The method&#39;s class, org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource, is available from the following locations:

    jar:file:/Users/miguelmunoz/.m2/repository/org/springframework/data/spring-data-commons/1.13.10.RELEASE/spring-data-commons-1.13.10.RELEASE.jar!/org/springframework/data/repository/config/AnnotationRepositoryConfigurationSource.class

The class hierarchy was loaded from the following locations:

    org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource: file:/Users/miguelmunoz/.m2/repository/org/springframework/data/spring-data-commons/1.13.10.RELEASE/spring-data-commons-1.13.10.RELEASE.jar
    org.springframework.data.repository.config.RepositoryConfigurationSourceSupport: file:/Users/miguelmunoz/.m2/repository/org/springframework/data/spring-data-commons/1.13.10.RELEASE/spring-data-commons-1.13.10.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource

I have no idea how to fix this. I have checked in a minimum reproducible test case at https://github.com/SwingGuy1024/dummy.artifact-MRTC

My pom file looks like this:

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
        xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
        xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0
        http://maven.apache.org/maven-v4_0_0.xsd">
	&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
	&lt;groupId&gt;dummy&lt;/groupId&gt;
	&lt;artifactId&gt;dummy.artifact&lt;/artifactId&gt;
	&lt;packaging&gt;jar&lt;/packaging&gt;
	&lt;name&gt;dummy.artifact&lt;/name&gt;
	&lt;version&gt;1.0&lt;/version&gt;
	&lt;properties&gt;
		&lt;java.version&gt;1.8&lt;/java.version&gt;
		&lt;maven.compiler.source&gt;${java.version}&lt;/maven.compiler.source&gt;
		&lt;maven.compiler.target&gt;${java.version}&lt;/maven.compiler.target&gt;
		&lt;springfox-version&gt;2.9.2&lt;/springfox-version&gt;
	&lt;/properties&gt;
	&lt;parent&gt;
		&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
		&lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
		&lt;version&gt;2.1.7.RELEASE&lt;/version&gt;
		&lt;!--&lt;version&gt;2.3.3.RELEASE&lt;/version&gt;--&gt; &lt;!--I tried both. Neither version worked.--&gt;
	&lt;/parent&gt;
	&lt;build&gt;
		&lt;sourceDirectory&gt;src/main/java&lt;/sourceDirectory&gt;
		&lt;plugins&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
				&lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
				&lt;executions&gt;
					&lt;execution&gt;
						&lt;goals&gt;
							&lt;goal&gt;repackage&lt;/goal&gt;
						&lt;/goals&gt;
					&lt;/execution&gt;
				&lt;/executions&gt;
			&lt;/plugin&gt;
		&lt;/plugins&gt;
	&lt;/build&gt;
	&lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
		    &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
		    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
		    &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-starter-jersey&lt;/artifactId&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.h2database&lt;/groupId&gt;
			&lt;artifactId&gt;h2&lt;/artifactId&gt;
			&lt;scope&gt;runtime&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
			&lt;scope&gt;test&lt;/scope&gt;
		&lt;/dependency&gt;

		&lt;!--SpringFox dependencies --&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;io.springfox&lt;/groupId&gt;
			&lt;artifactId&gt;springfox-swagger2&lt;/artifactId&gt;
			&lt;version&gt;${springfox-version}&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;io.springfox&lt;/groupId&gt;
			&lt;artifactId&gt;springfox-swagger-ui&lt;/artifactId&gt;
			&lt;version&gt;${springfox-version}&lt;/version&gt;
		&lt;/dependency&gt;

		&lt;dependency&gt;
			&lt;!--Handles serialization/deserialization of new Java Date/Time classes--&gt;
			&lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
			&lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;
		&lt;/dependency&gt;

		&lt;!-- Bean Validation API support --&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;javax.validation&lt;/groupId&gt;
			&lt;artifactId&gt;validation-api&lt;/artifactId&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
			&lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
			&lt;version&gt;2.10.1&lt;/version&gt;
		&lt;/dependency&gt;

	&lt;/dependencies&gt;
	&lt;dependencyManagement&gt;
		&lt;dependencies&gt;
			&lt;dependency&gt;
				&lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
				&lt;artifactId&gt;spring-data-releasetrain&lt;/artifactId&gt;
				&lt;version&gt;Neumann-SR4&lt;/version&gt;
				&lt;scope&gt;import&lt;/scope&gt;
				&lt;type&gt;pom&lt;/type&gt;
			&lt;/dependency&gt;
		&lt;/dependencies&gt;
	&lt;/dependencyManagement&gt;
&lt;/project&gt;

Addendum: As far as I can tell, I only have a single version of AnnotationRepositoryConfigurationSource, which is in the spring-data-commons repository. As I understand it, the versions of spring-data should be determined by the dependencyManagement section of my pom.xml file, where I specify the spring-data-releasetrain. I've tried several different values for that, but none of them work. The one specified here, Neumann-SR4, is the most recent one. But it doesn't give me the most recent version of spring-data-commons.

Addendum 2: Changes suggested by gtiwari333, below

I made the following changes and checked them into the GitHub repository. And I still have a problem.

  1. I moved classes RFC3339DateFormat and Swagger2SpringBoot to the dummy package and adjusted the parameters to the @ComponentScan annotation.
  2. I renamed CTwo to CTwoDto, and created a new CTwo class in a new dummy.entity package.
  3. The repository now uses to the new CTwo entity class
  4. I bumped the Spring-Boot version up to 2.3.3.RELEASE. (2.3.4 gives me a compiler error in a swagger-generated file — it can't find javax.servlet.http.HttpServletRequest)
  5. I removed three dependencies: jackson-datatype-jsr310, validation-api, and jackson-annotations
  6. I remove the dependencyManagement section from the pom file.
  7. I fiddled with the logging levels.

(These changes take me to the original bug that led me to create this MRTC.)

I still get an error message, although a different one.

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.&lt;init&gt;(AnnotationRepositoryConfigurationSource.java:126)

The following method did not exist:

    org.springframework.core.type.AnnotationMetadata.introspect(Ljava/lang/Class;)Lorg/springframework/core/type/AnnotationMetadata;

The method&#39;s class, org.springframework.core.type.AnnotationMetadata, is available from the following locations:

    jar:file:/Users/miguelmunoz/.m2/repository/org/springframework/spring-core/5.1.9.RELEASE/spring-core-5.1.9.RELEASE.jar!/org/springframework/core/type/AnnotationMetadata.class

It was loaded from the following location:

    file:/Users/miguelmunoz/.m2/repository/org/springframework/spring-core/5.1.9.RELEASE/spring-core-5.1.9.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.core.type.AnnotationMetadata

Once again, I only have a single version of the class in question.

答案1

得分: 1

我看到你的代码存在几个问题。以下是可能导致你所面临问题的其中一个或全部问题。

  1. 你的代码中没有在根包 dummy 下找到 dummy.invoker.Swagger2SpringBoot。Spring Boot 建议将 @SpringBootApplication 类放在根包中,这样它会自动扫描所有的组件和仓库,而不需要手动扫描。
    如果你一定要将这个类放在 dummy.invoker 包内,那么请进行以下操作,以便它可以扫描到 Repository 类:
    @EnableJpaRepositories(basePackages = {"dummy.repository"})

另外,

@EntityScan(basePackages = {"dummy.model"}) 来扫描 CTwo 实体类

参考:https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-locating-the-main-class

  1. CTwo 不是一个合适的实体类。但你在 CTwoRepository 中使用了它。将它改成一个实体类,并加上 @Id 注解
@Entity
public class CTwo   {
  @JsonProperty("id")
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Integer id = null;

额外注意事项:

  1. 没有必要覆盖 springframework.data 版本。从 pom.xml 中删除这部分。Spring 的 spring-boot-starter-data-jpa 会自动引入与给定 Spring Boot 版本兼容的正确版本。
<!-- 删除以下部分 -->
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-releasetrain</artifactId>
            <version>Neumann-SR4</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
    </dependencies>
</dependencyManagement>
  1. Repository 类不需要同时使用 @Repository@Component 注解
@Repository
public interface CTwoRepository ...
  1. 不需要覆盖 jackson-annotations 版本。实际上,你不需要添加这个依赖。同时,也不需要定义 jackson-datatype-jsr310 和 validation-api,它们会被自动引入。

查看以下补丁,这些是在运行应用之前需要进行的更改:

另外,为什么使用旧版本的 Spring Boot?请将其更新到最新版本。

<!-- 更新 Spring Boot 版本为最新版本 -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.4.RELEASE</version>
</parent>

以上是你的代码部分的翻译。

英文:

I see several problems to your code. One or all of these may be causing the problems that you are facing.

  1. You do not have dummy.invoker.Swagger2SpringBoot at root package dummy. Spring Boot recommends you to put the @SpringBootApplication class at root package so that it scans all the components and repositories without having you to scan manually.
    If you must put this class inside the dummy.invoker package, then please do the following so that it scans the Repository class
    @EnableJpaRepositories(basePackages = {&quot;dummy.repository&quot;})

Also,

@EntityScan(basePackages = {&quot;dummy.model&quot;}) to scan the CTwo entity

See: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-locating-the-main-class

  1. CTwo is not a proper Entity class. But you are using it on CTwoRepository. Make it a Entity class with a @Id
@Entity
public class CTwo   {
  @JsonProperty(&quot;id&quot;)
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Integer id = null;

Extra notes:

  1. There's no need to override the springframework.data version. Remove this from pom.xml. Spring spring-boot-starter-data-jpa pulls the correct version that works well together with the given spring boot version.
 	&lt;dependencyManagement&gt;
		&lt;dependencies&gt;
			&lt;dependency&gt;
				&lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
				&lt;artifactId&gt;spring-data-releasetrain&lt;/artifactId&gt;
				&lt;version&gt;Neumann-SR4&lt;/version&gt;
				&lt;scope&gt;import&lt;/scope&gt;
				&lt;type&gt;pom&lt;/type&gt;
			&lt;/dependency&gt;
		&lt;/dependencies&gt;
	&lt;/dependencyManagement&gt;
  1. No need to put @Repository and @Component at repository class
@Repository
@Component
public interface CTwoRepository ...
  1. No need to override the jackson-annotations version. In fact you don't need to put this dependency at all. Also, no need to define the jackson-datatype-jsr310, validation-api. They are pulled transitively.

See this patch for the changes that you need to do before you can run your app:

Also, why are you using the old spring boot version? Please update that to latest.

Index: src/main/java/dummy/repository/CTwoRepository.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
&lt;+&gt;UTF-8
===================================================================
--- src/main/java/dummy/repository/CTwoRepository.java	(revision 27a2e1045263f79fd3c490fce14b2640b12fa3a4)
+++ src/main/java/dummy/repository/CTwoRepository.java	(date 1601681768001)
@@ -12,7 +12,5 @@
  *
  * @author Miguel Mu\u00f1oz
  */
-@Repository
-@Component
 public interface CTwoRepository extends JpaRepository&lt;CTwo, Integer&gt; {
 }
Index: src/main/java/dummy/model/CTwo.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
&lt;+&gt;UTF-8
===================================================================
--- src/main/java/dummy/model/CTwo.java	(revision 27a2e1045263f79fd3c490fce14b2640b12fa3a4)
+++ src/main/java/dummy/model/CTwo.java	(date 1601681492814)
@@ -7,18 +7,22 @@
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import org.springframework.validation.annotation.Validated;
+
+import javax.persistence.*;
 import javax.validation.Valid;
 import javax.validation.constraints.*;
 
 /**
  * CTwo
  */
-@Validated
-@javax.annotation.Generated(value = &quot;io.swagger.codegen.v3.generators.java.SpringCodegen&quot;, date = &quot;2020-10-01T10:23:27.051Z[GMT]&quot;)
+//@Validated
+//@javax.annotation.Generated(value = &quot;io.swagger.codegen.v3.generators.java.SpringCodegen&quot;, date = &quot;2020-10-01T10:23:27.051Z[GMT]&quot;)
 @JsonInclude(JsonInclude.Include.NON_NULL)
-
+@Entity
 public class CTwo   {
   @JsonProperty(&quot;id&quot;)
+  @Id
+  @GeneratedValue(strategy = GenerationType.IDENTITY)
   private Integer id = null;
 
   @JsonProperty(&quot;name&quot;)
Index: pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
&lt;+&gt;UTF-8
===================================================================
--- pom.xml	(revision 27a2e1045263f79fd3c490fce14b2640b12fa3a4)
+++ pom.xml	(date 1601682065794)
@@ -15,8 +15,7 @@
 	&lt;parent&gt;
 		&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
 		&lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
-		&lt;version&gt;2.1.7.RELEASE&lt;/version&gt;
-		&lt;!--&lt;version&gt;2.3.3.RELEASE&lt;/version&gt;--&gt; &lt;!--I tried both. Neither version worked.--&gt;
+		&lt;version&gt;2.3.4.RELEASE&lt;/version&gt;
 	&lt;/parent&gt;
 	&lt;build&gt;
 		&lt;sourceDirectory&gt;src/main/java&lt;/sourceDirectory&gt;
@@ -74,55 +73,5 @@
 			&lt;version&gt;${springfox-version}&lt;/version&gt;
 		&lt;/dependency&gt;
 
-		&lt;!--&lt;dependency&gt;--&gt;
-		&lt;!--	&lt;groupId&gt;jakarta.xml.bind&lt;/groupId&gt;--&gt;
-		&lt;!--	&lt;artifactId&gt;jakarta.xml.bind-api&lt;/artifactId&gt;--&gt;
-		&lt;!--	&lt;version&gt;2.3.2&lt;/version&gt;--&gt;
-		&lt;!--&lt;/dependency&gt;--&gt;
-		
-		&lt;!--&amp;lt;!&amp;ndash; Runtime, com.sun.xml.bind module &amp;ndash;&amp;gt;--&gt;
-		&lt;!--&lt;dependency&gt;--&gt;
-		&lt;!--	&lt;groupId&gt;org.glassfish.jaxb&lt;/groupId&gt;--&gt;
-		&lt;!--	&lt;artifactId&gt;jaxb-runtime&lt;/artifactId&gt;--&gt;
-		&lt;!--	&lt;version&gt;2.3.2&lt;/version&gt;--&gt;
-		&lt;!--&lt;/dependency&gt;--&gt;
-
-		&lt;dependency&gt;
-			&lt;!--Handles serialization/deserialization of new Java Date/Time classes--&gt;
-			&lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
-			&lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;
-		&lt;/dependency&gt;
-		&lt;!-- Bean Validation API support --&gt;
-		&lt;dependency&gt;
-			&lt;groupId&gt;javax.validation&lt;/groupId&gt;
-			&lt;artifactId&gt;validation-api&lt;/artifactId&gt;
-		&lt;/dependency&gt;
-		&lt;dependency&gt;
-			&lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
-			&lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
-			&lt;version&gt;2.10.1&lt;/version&gt;
-		&lt;/dependency&gt;
-
-		&lt;!--&amp;lt;!&amp;ndash;Actuator&amp;ndash;&amp;gt;--&gt;
-		&lt;!--&lt;dependency&gt;--&gt;
-		&lt;!--	&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;--&gt;
-		&lt;!--	&lt;artifactId&gt;spring-boot-actuator-docs&lt;/artifactId&gt;--&gt;
-		&lt;!--	&lt;version&gt;1.5.10.RELEASE&lt;/version&gt;--&gt;
-		&lt;!--&lt;/dependency&gt;--&gt;
-		&lt;!--&lt;dependency&gt;--&gt;
-		&lt;!--	&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;--&gt;
-		&lt;!--	&lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;--&gt;
-		&lt;!--&lt;/dependency&gt;--&gt;
 	&lt;/dependencies&gt;
-	&lt;dependencyManagement&gt;
-		&lt;dependencies&gt;
-			&lt;dependency&gt;
-				&lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
-				&lt;artifactId&gt;spring-data-releasetrain&lt;/artifactId&gt;
-				&lt;version&gt;Neumann-SR4&lt;/version&gt;
-				&lt;scope&gt;import&lt;/scope&gt;
-				&lt;type&gt;pom&lt;/type&gt;
-			&lt;/dependency&gt;
-		&lt;/dependencies&gt;
-	&lt;/dependencyManagement&gt;
 &lt;/project&gt;
Index: src/main/java/dummy/invoker/Swagger2SpringBoot.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
&lt;+&gt;UTF-8
===================================================================
--- src/main/java/dummy/invoker/Swagger2SpringBoot.java	(revision 27a2e1045263f79fd3c490fce14b2640b12fa3a4)
+++ src/main/java/dummy/invoker/Swagger2SpringBoot.java	(date 1601681394614)
@@ -4,13 +4,17 @@
 import org.springframework.boot.ExitCodeGenerator;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
 import org.springframework.context.annotation.ComponentScan;
 
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
 import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
 @SpringBootApplication
 @EnableSwagger2
-@ComponentScan(basePackages = { &quot;dummy.invoker&quot;, &quot;dummy.api&quot; , &quot;dummy.config&quot;, &quot;dummy.repository&quot;})
+@EnableJpaRepositories(basePackages = {&quot;dummy.repository&quot;})
+@EntityScan(basePackages = {&quot;dummy.model&quot;})
+@ComponentScan(basePackages = { &quot;dummy.invoker&quot;, &quot;dummy.api&quot; , &quot;dummy.config&quot; })
 public class Swagger2SpringBoot implements CommandLineRunner {
 
     @Override

答案2

得分: 0

看起来你在 Spring 库之间有一个冲突 - 几乎相同的问题在这里有描述:

https://stackoverflow.com/questions/59564275/how-to-make-spring-data-lib-compatiable-in-spring-boot-2-x

提示:在尝试调试这种类型的错误时,从你得到的与问题相关的确切错误消息的一部分开始搜索(复制粘贴它)。如果一开始没有找到任何内容,尝试将其缩小到一些通用的东西,你会找到类似的问题。

还值得注意的是,输出的末尾有一条描述如何修复问题的消息:

操作:

更正应用程序的类路径,以便它包含 org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource 的单个兼容版本。

这表明有超过两个兼容版本的“某个类”。如果你专门搜索被提到的有问题的类,你很可能会找到很多遇到完全相同问题的人 + 他们的解决方案。

英文:

Looks like you have a conflict between spring libs - almost identical problem is described here:

https://stackoverflow.com/questions/59564275/how-to-make-spring-data-lib-compatiable-in-spring-boot-2-x

Tip: When trying to debug this sort of error, start with a search for a portion of the exact error message you're getting that seems relevant (copy paste it). Try to narrow it down to something generic if nothing shows up immediately and you'll find similar problems.

Also worth noting there's a message at the end of the output that describes what you need to do to fix the problem:

Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource

This suggests there are more than two compatible versions of "some class". If you search specifically for the problematic class mentioned, you'll likely find a lot more people with the exact same problem + their solutions.

huangapple
  • 本文由 发表于 2020年10月2日 20:43:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/64171751.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定