How to create a restful-style webservcie, based on maven without using a framework like CXF?

problem description

A novice has just started webservice, of java. I want to create a restful-style webservice based on maven (data transfer format is json).
however, most of the data on the network is integrated with spring or webservcie created by frameworks such as cxf. What should I do if I don"t use cxf or other frameworks?
in other words: can I directly build a webservice JAX-RS project, then directly write the code, deploy and release it to run on tomcat? Is there a more detailed example of
? Thank you very much!

the environmental background of the problems and what methods you have tried

I have now written a restful-style class TestReast, but how should I publish it?

@Path("/testRest")
public class TestReast {

    @GET
    @Produces("application/json")
    @Path("login")
    public String login(@QueryParam("name")String name,@QueryParam("password")String password){
        return "say"+name+password;
    }
    @POST
    @Produces("application/json")
    @Path("login2")
    public String login2(@FormParam("name")String name,@FormParam("password")String password){
        return "name:"+name+",password:"+password;
    }
}

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Aug.11,2021

JAX-RS is the API specification, and it is not implemented. Tomcat does not include the implementation of JAX-RS, so you need to integrate an implementation library of JAX-RS. If you do not need cxf, you can use Jersey and so on. To find out, there are many examples of using Jersey as a rest service.

Menu