2
@Path("test")
public TestResource {

    @GET
    public Response testGet() {
        return Response.ok().build();
    }

}

From the spring boot documentation, the section on JAX-RS and Jersey, "All the registered endpoints should be @Components with HTTP resource annotations (@GET etc.), e.g.". The above resource still works without the @Component annotation. What would I be breaking by leaving out the @Component annotation?

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
Vinay Nagaraj
  • 1,162
  • 14
  • 26

1 Answers1

1

"To enable JAX-RS resources to work Spring functionality that requires proxying, such as Spring transaction management (with @Transactional), Spring Security and aspect oriented programming (such as @Aspect), the resources must themselves be managed by Spring, by annotating with @Component, @Service, @Controller or @Repository:"

Vinay Nagaraj
  • 1,162
  • 14
  • 26
  • Additionally you must also be aware that the life-cycle of Spring managed resources is different then normal Jersey managed resources. For details look at my answer [here](https://stackoverflow.com/a/63931292/3213514). – Rahul Khimasia Sep 17 '20 at 04:50