如果我有相同的 2 requestMapping URL,params(no params) 并生成类型(JSON),我想了解为什么 Spring 应用程序会启动。默认情况下,这些方法正在生成 JSON(我测试了 XML 和其他方法,但出现 500 错误,我没有依赖项。我想知道这是 Intellij 还是 Spring 问题,或者如果我将 Get
放在第二个,那么启动并覆盖第二个 produces = MediaType.APPLICATION_JSON_VALUE
是否正常我也收到错误。这是有效的示例:
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ExampleDTO>> getMethodd1() {
return ResponseEntity.ok(ExampleStore.available);
}
@GetMapping()
public ResponseEntity<List<ExampleDTO>> getMethodd2() {
return ResponseEntity.ok(ExampleStore.available);
}
这个例子不再开始:
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ExampleDTO>> getMethodd1() {
return ResponseEntity.ok(ExampleStore.available);
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ExampleDTO>> getMethodd2() {
return ResponseEntity.ok(ExampleStore.available);
}
PS:我知道请求的参数或网址应该不同。