为了账号安全,请及时绑定邮箱和手机立即绑定

spring boot 写两个mapping就会报错为什么?

spring boot 写两个mapping就会报错为什么?

qq_矜我意_1 2018-01-09 03:30:30
@GetMapping(name = "/hello")public String hello() {return "hello";}@GetMapping(name = "/hello2")public String hello2() {return "hello";}当再写@GetMapping(name = "/hello2")的方法时报错。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.除此之外,只写一个mapping @GetMapping(name = "/hello") http://localhost:8080/hello可以访问到该方法http://localhost:8080/xxxx也可以访问到该方法
查看完整描述

1 回答

?
慕尼黑2545441

TA贡献2条经验 获得超1个赞

sping的配置文件有问题

查看完整回答
1 反对 回复 2018-01-09
  • 1 回答
  • 0 关注
  • 1185 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信