こんにちは、サンプルに単純な 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);
}
}
そして、SpringBoot を開始するための SampleController があります。
@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.
問題はどこにありますか?1 つの RestController に複数の RequestMappings を含めることはできませんか?
返信ありがとうございます