Simple REST method returning an object

In the previous method, we returned a string. Let's create a method that returns a proper JSON response. Take a look at the following method:

    @GetMapping("/welcome-with-object")    public WelcomeBean welcomeWithObject() {      return new WelcomeBean("Hello World");    }

This preceding method returns a simple WelcomeBean initialized with a message: "Hello World".

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.