"Ambiguous search mapping detected" SpringBoot 添加 Springfox 3.0.0 后抛出

"Ambiguous search mapping detected" thrown after adding Springfox 3.0.0 to SpringBoot

我有一个 SpringBoot 应用程序 (spring-boot-starter-parent:2.4.0),我想使用 Swagger。我遵循了这个 Baeldung-Tutorial,不幸的是我在启动时遇到了这个异常:

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.IllegalStateException: Ambiguous search mapping detected.

这是因为我在某些情况下会在我的存储库中重载方法,如下所示:

Page<Message> findByConversationId(Long conversationId, Pageable pageable);
List<Message> findByConversationId(Long conversationId);

例外说明这两种方法

are mapped to /findByConversationId! Tweak configuration to get to unambiguous paths!

有什么办法可以解决这个问题吗? 谢谢!

这不是您问题的答案,但可能对您有所帮助。 考虑使用 springdoc 而不是 Springfox。它是一个较新的库,比 Springfox 更易于使用且更不容易出错。我们在 2 年前搬到了这里,我们很高兴我们做到了。网上有很好的文档和教程:

它也非常活跃,您的问题通常很快就会在 github page 上得到解答。