org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper' defined in URL [jar:file:/D:/Soft_dev/maven/apache-maven-repository/io/springfox/springfox-spring-web/3.0.0/springfox-spring-web-3.0.0.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL [jar:file:/D:/Soft_dev/maven/apache-maven-repository/io/springfox/springfox-spring-webmvc/3.0.0/springfox-spring-webmvc-3.0.0.jar!/springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'databaseController' method
com.fast.server.controller.DatabaseController#getDatabaseByPage(DatabasePageBody)
to {POST [/database/list]}: There is already 'databaseController' bean method
这个错误似乎是由于在同一个控制器类中有两个相同路径和相同 HTTP 方法的方法。
Spring MVC 在初始化时无法确定要使用哪个方法来处理请求。
要解决这个问题,你可以通过以下几种方式之一:
-
修改方法路径或HTTP方法: 确保每个方法的路径或HTTP方法是唯一的,这样就不会出现冲突。例如,将其中一个方法的路径或HTTP方法修改为与另一个方法不同。
-
使用不同的控制器类: 将其中一个方法移动到另一个控制器类中,这样就不会有冲突。
-
使用@RequestMapping注解进行细粒度控制: 如果你使用的是 @RequestMapping 注解,可以通过使用更具体的路径和条件来进一步细化请求映射,从而避免冲突。
(检查对应的controller中是否出现了相同路径的api
)