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

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

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

问题

我正在开发 Spring Boot JPA Gridle 项目。当前 Swagger 正在运行,但在进行 DTO 时出现了错误。各个模块似乎发生了冲突。

在我安装了 swagger 模块并进行了 swagger 设置后,再安装 DTO 模块时出现了错误。以下模块产生了错误:

compile 'org.springframework.boot:spring-boot-starter-hateoas'

错误信息如下。

启动应用程序上下文时出错。要显示条件报告,请使用 'debug' 启用调试重新运行应用程序。
2020-03-17 01:26:38.657 ERROR 4688 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
应用程序启动失败
***************************

描述:

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

    springfox.documentation.spring.web.plugins.DocumentationPluginsManager.createContextBuilder(DocumentationPluginsManager.java:152)

以下方法不存在:

    org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin;

该方法的类 org.springframework.plugin.core.PluginRegistry 可在以下位置找到:

    jar:file:/Users/****/.gradle/caches/modules-2/files-2.1/org.springframework.plugin/spring-plugin-core/2.0.0.RELEASE/95fc8c13037630f4aba9c51141f535becec00fe6/spring-plugin-core-2.0.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class

它是从以下位置加载的:

    file:/Users/****/.gradle/caches/modules-2/files-2.1/org.springframework.plugin/spring-plugin-core/2.0.0.RELEASE/95fc8c13037630f4aba9c51141f535becec00fe6/spring-plugin-core-2.0.0.RELEASE.jar


操作:

纠正应用程序的类路径,以便包含单个兼容版本的 org.springframework.plugin.core.PluginRegistry


进程以退出代码 1 结束

我尝试过的一些搜索结果如下。

compile group: 'org.springframework.plugin', name: 'spring-plugin-core', version: '2.0.0.RELEASE'

compile group: 'io.springfox', name: 'springfox-data-rest', version: '2.9.2'

但是它们都没有帮助到我。

有其他人遇到过相同的问题吗?

还有其他解决这个问题的方法吗?

英文:

I'm working on the Spring boot JPA Gridle project. Current Swagger is running, and an error occurs while DTO is in progress. Modules seem to be colliding with each other.

An error occurs when I install a swagger module, proceed with the swagger, and install the module for DTO. The following modules produce an error:

compile 'org.springframework.boot:spring-boot-starter-hateoas'

And the error is as follows.

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-17 01:26:38.657 ERROR 4688 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

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

    springfox.documentation.spring.web.plugins.DocumentationPluginsManager.createContextBuilder(DocumentationPluginsManager.java:152)

The following method did not exist:

    org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin;

The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:

    jar:file:/Users/****/.gradle/caches/modules-2/files-2.1/org.springframework.plugin/spring-plugin-core/2.0.0.RELEASE/95fc8c13037630f4aba9c51141f535becec00fe6/spring-plugin-core-2.0.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class

It was loaded from the following location:

    file:/Users/****/.gradle/caches/modules-2/files-2.1/org.springframework.plugin/spring-plugin-core/2.0.0.RELEASE/95fc8c13037630f4aba9c51141f535becec00fe6/spring-plugin-core-2.0.0.RELEASE.jar


Action:

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


Process finished with exit code 1

The things I tried through the search are as well.

compile group: 'org.springframework.plugin', name: 'spring-plugin-core', version: '2.0.0.RELEASE'

compile group: 'io.springfox', name: 'springfox-data-rest', version: '2.9.2'

Neither of them helped me.

Does anyone have the same problem as me?

Is there any other way to solve this problem?

答案1

得分: 4

以下是翻译好的部分:

问题是Swagger和Hateoas模块之间的冲突。许多搜索结果已经找到了解决方案。

解决方案是添加一个新的模块并为其注册Bean

compile group: 'org.springframework.plugin', name: 'spring-plugin-core', version: '1.2.0.RELEASE'

SwaggerConfig.java

public class SwaggerConfig {

    @Bean
    public LinkDiscoverers discoverers() {
        List<LinkDiscoverer> plugins = new ArrayList<>();
        plugins.add(new CollectionJsonLinkDiscoverer());
        return new LinkDiscoverers(SimplePluginRegistry.create(plugins));
    }

}
英文:

The problem was a conflict between Swagger and Hateoas modules. A number of search results have found a solution.

The solution was to add a new module and register Bean for it.

compile group: &#39;org.springframework.plugin&#39;, name: &#39;spring-plugin-core&#39;, version: &#39;1.2.0.RELEASE&#39;

SwaggerConfig.java

public class SwaggerConfig {

    @Bean
    public LinkDiscoverers discoverers() {
        List&lt;LinkDiscoverer&gt; plugins = new ArrayList&lt;&gt;();
        plugins.add(new CollectionJsonLinkDiscoverer());
        return new LinkDiscoverers(SimplePluginRegistry.create(plugins));
    }

}

答案2

得分: 0

对我来说,问题是 JPA 和 Hateoas 依赖之间的冲突。

对我而言,解决方案是移除 JPA 依赖,因为我希望使用 Hateoas 模块。

将以下内容从这样更改:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>org.springframework.hateoas</groupId>
    <artifactId>spring-hateoas</artifactId>
</dependency>

更改为:

<dependency>
    <groupId>org.springframework.hateoas</groupId>
    <artifactId>spring-hateoas</artifactId>
</dependency>
英文:

For me the problem was a conflict between JPA and Hateoas dependencies.

The solution for me was to remove the JPA dependency since I was interested in using the Hateoas module instead.

Changed this:

    &lt;dependency&gt;
		&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
		&lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
		&lt;scope&gt;provided&lt;/scope&gt;
	&lt;/dependency&gt;

	&lt;dependency&gt;
		&lt;groupId&gt;org.springframework.hateoas&lt;/groupId&gt;
		&lt;artifactId&gt;spring-hateoas&lt;/artifactId&gt;
	&lt;/dependency&gt;

To this:

	&lt;dependency&gt;
		&lt;groupId&gt;org.springframework.hateoas&lt;/groupId&gt;
		&lt;artifactId&gt;spring-hateoas&lt;/artifactId&gt;
	&lt;/dependency&gt;

答案3

得分: 0

对我来说,Swagger和JPA之间存在冲突,因此我不得不将SpringBoot从2.1.9-RELEASE升级到2.7.5。

英文:

For me was a conflict between the Swagger and the JPA, so I had to upgrade the SpringBoot from 2.1.9-RELEASE to 2.7.5.

huangapple
  • 本文由 发表于 2020年3月17日 00:33:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/60709789.html
匿名

发表评论

匿名网友

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

确定