亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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 關注
  • 1240 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號