You need to perform the following steps to complete this recipe:
- We are going to build a JAX-RS-based application, so we will start by preparing the application:
@ApplicationPath("webresources")public class Application extends javax.ws.rs.core.Application {}
- Then, we will create a User class as our main object:
public class User implements Serializable { private String name; private String email; //DO NOT FORGET TO ADD THE GETTERS AND SETTERS}
- Our User class doesn't have a default constructor, so Jakarta CDI doesn't know how to construct the class when it tries to inject it. Therefore, we need to create a factory class and use the @Produces annotation over its methods:
public class UserFactory implements Serializable{ ...