@GetMapping(name = "/hello")public String hello() {return "hello";}@GetMapping(name = "/hello2")public String hello2() {return "hello";}當(dāng)再寫@GetMapping(name = "/hello2")的方法時(shí)報(bào)錯(cuò)。Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'helloWord' method?public java.lang.String com.java.HelloWord.hello2()to {[],methods=[GET]}: There is already 'helloWord' bean methodpublic java.lang.String com.java.HelloWord.hello() mapped.除此之外,只寫一個(gè)mapping @GetMapping(name = "/hello")?http://localhost:8080/hello可以訪問到該方法http://localhost:8080/xxxx也可以訪問到該方法
添加回答
舉報(bào)
0/150
提交
取消