Reputation: 41
This works, I am able to make a request in postman for this Service.
@RestController
@Path("sample")
public class SampleClass {
@GET
@Path(value = "/s1")
public Object get() {
//Something
}
}
The problem is when I try to use @RequestMapping
instead of @Path
, I get a
404 Not Found
Error.
@RestController
@RequestMapping("sample")
public class CommonService {
@GetMapping(value = "/s1", produces = MediaType.APPLICATION_JSON)
public Object get() {
//Something
}
}
What I am doing wrong here?
Upvotes: 1
Views: 733
Reputation: 41
After a while, I found out that for the JAX-RS (@Path) I had configured in web.xml file a different route "something". JAX-RS: localhost:8080**/something**/sample/s1 Spring Rest Services: localhost:8080/sample/s1
I was also missing a "/" in the Spring Rest Service. @RequestMapping("**/**sample")
Full code bellow:
@RestController
@RequestMapping("/sample")
public class CommonService {
@GetMapping(value = "/s1", produces = MediaType.APPLICATION_JSON)
public Object get() {
//Something
}
}
Upvotes: 2