@boot注解在Spring Boot中的spring-boot-starter-jersey资源上的用途

@boot注解在Spring Boot中的spring-boot-starter-jersey资源上的用途

问题描述:

@Path("test")
public TestResource {

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

}

从Spring Boot文档的JAX-RS和Jersey上的部分开始,例如,所有注册的端点都应该是带有HTTP资源注释的@Components(@GET等)".上面的资源仍然可以在没有@Component批注的情况下使用.省略@Component注释会破坏什么?

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?

为了使JAX-RS资源能够运行需要代理的Spring功能,例如Spring事务管理(使用@Transactional),Spring Security和面向方面的编程(例如@Aspect),资源本身必须由Spring管理,方法是使用@ Component,@ Service,@ Controller或@Repository进行注释:"

"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:"