The Spring framework’s @RestController annotation is equivalent to using the @Controller and @ResponseBody
annotations together. As such, it is redundant to add a @ResponseBody annotation when the class is already annotated with
@RestController.
Remove the @ResponseBody annotation from the class or method.
@RestController
public class MyController {
@ResponseBody // Noncompliant, the @RestController annotation already implies @ResponseBody
@RequestMapping("/hello")
public String hello() {
return "Hello World!";
}
}
@RestController
public class MyController {
@RequestMapping("/hello")
public String hello() {
return "Hello World!";
}
}
@RestController
@ResponseBody // Noncompliant, the @RestController annotation already implies @ResponseBody
public class MyController {
@RequestMapping("/hello")
public String hello() {
return "Hello World!";
}
}
@RestController
public class MyController {
@RequestMapping("/hello")
public String hello() {
return "Hello World!";
}
}