嗨,我的Sample中有一个简单的RestController:
@RestController
public class PersonController {
@RequestMapping(name = "/getName",method = GET)
public String getName() {
return "MyName";
}
@RequestMapping(name = "/getNumber",method = GET)
public Double getNumber(){
return new Double(0.0);
}
}
我有SampleController用于启动SpringBoot:
@SpringBootApplication
@Controller
public class SampleController {
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class,args);
}
}
当我尝试运行SampleCotroller时,会发生以下异常:
Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'personController' bean method
public java.lang.Double com.web.communication.PersonController.getNumber()
to {[],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'personController' bean method
public java.lang.String com.web.communication.PersonController.getName() mapped.
问题出在哪里?一个RestController中不能有更多的RequestMappings?
非常感谢您的回复
最佳答案
原文链接:https://www.f2er.com/springboot/432046.html