@GetMapping("/customHeader") ResponseEntity<String> customHeader() { HttpHeaders headers = new HttpHeaders(); headers.add("Custom-Header", "foo"); return new ResponseEntity<>( "Custom header ", headers, HttpStatus.OK); } //Simple way @GetMapping("/hello") ResponseEntity<String> hello() { return ResponseEntity.ok("Hello World!"); }Sour:ecwww.lautturi.com