Hey friends, I keep getting an error when I try to return a buffered image with spring. Here is the error below:
2023-03-14T13:45:04.645-04:00 WARN 81359 --- [nio-8080-exec-8] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class java.awt.image.BufferedImage] with preset Content-Type 'null']
Here is the GetMapping code.
@GetMapping(path = "/long", produces = "image/png")
public BufferedImage createLong() {
try {
return ImageIO.read(new File("/Users/ntdi/Documents/planium/src/main/resources/static/Ntdi_world_1200px-01.png"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}```