Caused by: java.lang.IllegalStateException: Ambiguou There is already ‘XXXXXXController‘ bean method

created at 08-11-2021 views: 42

error message

Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘com.offcn.seckill.feign.SeckillGoodsFeignn’ method
com.offcn.seckill.feign.SeckillGoodsFeignn#findPage(SeckillGoods, int, int)
to {POST /seckillGoods/search/{page}/{size}}: There is already ‘seckillGoodsController’ bean method

Reason

there are two or more RequestMapping or GetMapping with the same name

solution

  1. Check whether the URL of the same RequestMapping in all other classes is the same, if there is a different URL, you can modify it.
  2. In the remote call interface using feign, the RequestMapping on the interface is the same as the RequestMapping url of the called class, which causes the problem, just configure the url of the interface RequestMpping into the method of this interface, and remove the interface RequestMapping. url configuration.

 URL of  RequestMapping

for example, replaced as follows:

configure url of RequestMpping into the method of this interface

created at:08-11-2021
edited at: 08-11-2021: