I am testing RESTful service with JAX-RS 2. Below is my project and my classes.
@ApplicationPath("/test/*")
public class MyApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> clazz = new HashSet<>();
clazz.add(UserResource.class);
System.out.println("getClass");
return clazz;
}
The resource class like:
@Path("/user")
public class UserResource {
@GET
@Produces("application/xml")
public Response getUser() {
return Response.created(URI.create("/dd")).build();
}
@GET
public Response getDefaultUser() {
System.out.println("getDefaultUser");
return Response.created(URI.create("/dd")).build();
}
}
When I test the service using http://localhost:8082/dt/test/user
, I got 404 error.