Spring 引导中 spring-boot-starter-jersey 资源上 @Component 注释的目的
Purpose of @Component annotation on spring-boot-starter-jersey resources in Spring boot
@Path("test")
public TestResource {
@GET
public Response testGet() {
return Response.ok().build();
}
}
来自 spring 引导文档,关于 JAX-RS 和 Jersey 的部分,"All the registered endpoints should be @Components with HTTP resource annotations (@GET etc.), e.g."。上面的资源在没有 @Component 注释的情况下仍然有效。省略 @Component 注释会破坏什么?
"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:"
@Path("test")
public TestResource {
@GET
public Response testGet() {
return Response.ok().build();
}
}
来自 spring 引导文档,关于 JAX-RS 和 Jersey 的部分,"All the registered endpoints should be @Components with HTTP resource annotations (@GET etc.), e.g."。上面的资源在没有 @Component 注释的情况下仍然有效。省略 @Component 注释会破坏什么?
"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:"