javax.ws.rs.NotFoundException: Could not find resource for full path with RESTEasy and Wildfly 8.1.0.Final

前端 未结 7 2173
长情又很酷
长情又很酷 2020-12-06 01:59

I am facing following problem. I have spent more than 3 days on this but cannot find a solution. Please guide me what I am doing wrong here. I am new to Resteasy with wildfl

7条回答
  •  长情又很酷
    2020-12-06 02:18

    • Base:

      (1) http://localhost:8080/admin-ws  (I assume `admin-ws` is the app name)
      
    • @ApplicationPath("/services") == append /services to Base

      (2) http://localhost:8080/admin-ws/services
      
    • @Path("/user") == append /user to previous

      (3) http://localhost:8080/admin-ws/services/user
      
    • @Path("/services/user/getUser") == append /services/user/getUser to previous

      (4) http://localhost:8080/admin-ws/services/user/services/user/getUser
                 //This is the winner with your current set up
      
    • What you are using:

      http://localhost:8080/admin-ws/services/user/getUser
      

      What's different?

    How it Should Look : to follow good REST (naming included) practices

    @ApplicationPath("/services")
    public class WebConfig extends Application {
    }
    
    @Path("/users")
    public class UserResource implements Serializable {
    
        @Inject
        private UserService userService;
    
        @GET
        @Path("/{id}")
        @Produces(MediaType.APPLICATION_JSON)
        public UserWsPojo getUser(@PathParam("id") String id) {
            UserWsPojo uwp = userService.getUserById(id);
            return uwp;
        }
    }
    

    Access:

    http://localhost:8080/admin-ws/services/users/12344
                                           // some user id
    

提交回复
热议问题