From the course: Java EE: RESTful Service with JAX-RS 2.0
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Add the media types
From the course: Java EE: RESTful Service with JAX-RS 2.0
Add the media types
- [Instructor] Okay, we're back in our book resource class. Let's add some producer's annotations to the get all book method and let's hit, produce JSON data. So, we start by annotating the method, our producers, and we pass it our media type, application, JSON. And we're gonna annotate some more of our methods. The next method we're going to annotate is going to be our Save Book method. Now remember, this method produces and consumes JSON data. So, we're gonna annotate it with both produces and consumes annotations. So again, we are starting to annotate our media type, like so. And then we're going to consume our JSON, like so. Again, application JSON. Now we're going to finish off by annotating our, Get Book By ISBN method. This method produces JSON. So again, annotating this method in the same manner as the other ones. Like so. So, now our methods are annotated. We can deploy our application. And by using Postman, which we installed in a previous video, we can test our endpoints…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Define the REST contract3m 42s
-
Inheritance or XML configuration3m 25s
-
Define the API root3m 14s
-
Create the resource entity5m 37s
-
Create the resource methods6m 16s
-
Path parameters2m 35s
-
Add path paramaters3m 21s
-
@Consumes and @Produces2m 7s
-
Add the media types4m 56s
-
Challenge: Add resource methods31s
-
Solution: Add resource methods1m 56s
-
-
-
-
-