【发布时间】:2016-11-03 16:27:53
【问题描述】:
我的 Spring boot(1.4.0 RELEASE) 应用中有两个 Rest 控制器:
@RestController("/ctrl")
public class TestController {
@GetMapping
public void test() {
}
}
@RestController("/ctrl2")
public class TestController2 {
@GetMapping
public void test() {
}
}
当我运行 Spring Boot 应用程序时:
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map '/ctrl2' method
public void com.xxx.controller.TestController2.test()
to {[],methods=[GET]}: There is already '/ctrl' bean method
public void com.xxx.controller.TestController.test() mapped.
如果我删除一个控制器,一切都会好起来的,应用程序可以正常启动。那么问题出在哪里?
【问题讨论】:
-
@Veeram 即使更改为完全不同的路径也无法正常工作
标签: java spring spring-boot spring-restcontroller