简体   繁体   中英

Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'com.sportswin.soa.spark.controller.ISparkGameUserController' method

Today when I start the spring boot project, shows error like this:

2022-01-21 14:52:04.659 ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL [jar:file:/root/soa-spark-service-1.0.0-SNAPSHOT.jar!/BOOT-INF/lib/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 'com.sportswin.soa.spark.controller.ISparkGameUserController' method 
public abstract com.sportswin.soa.misc.contract.response.Response com.sportswin.soa.spark.controller.ISparkGameUserController.sparkGameUserFirstVote(com.sportswin.soa.spark.contract.request.vote.SparkGameUserVoteRequest)
to {POST /spark/game/user/vote/first}: There is already 'sparkGameUserController' bean method
public com.sportswin.soa.misc.contract.response.Response com.sportswin.soa.spark.controller.impl.SparkGameUserController.sparkGameUserFirstVote(com.sportswin.soa.spark.contract.request.vote.SparkGameUserVoteRequest) mapped.
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769) ~[spring-beans-5.1.13.RELEASE.jar!/:5.1.13.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:218) ~[spring-beans-5.1.13.RELEASE.jar!/:5.1.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1340) ~[spring-beans-5.1.13.RELEASE.jar!/:5.1.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1186) ~[spring-beans-5.1.13.RELEASE.jar!/:5.1.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.13.RELEASE.jar!/:5.1.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.13.RELEASE.jar!/:5.1.13.RELEASE]

I check the code, and did not found the Controller two method define with the same path. this is the rest controller method define:

    @GetMapping("/vote/first/{gameId}")
    Response<List<SparkGameUserVoteFirstResponse>> queryFirstVoteSparkGameUser(@PathVariable(value = "gameId") Long gameId);

    @PostMapping("/vote/first")
    Response sparkGameUserFirstVote(@RequestBody  @Valid SparkGameUserVoteRequest request);

why did this happen? what should I do to fix it?I feel like the controller initial twice.

Try running a global text searching on text "/vote/first"? (Based on error msg you may have an api prefix "/spark/game/user" on this controller. Maybe somewhere else also produce the contacted api "/spark/game/user/vote/first")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM