gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 13:26:47 25 4
gpt4 key购买 nike

@Path("test")
public TestResource {

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

}

来自 spring boot 文档,关于 JAX-RS 和 Jersey 的部分,“所有注册的端点应该是带有 HTTP 资源注释(@GET 等)的 @Components,例如”。上面的资源在没有 @Component 注解的情况下仍然可以工作。省略 @Component 注释会破坏什么?

最佳答案

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

关于java - Spring boot中spring-boot-starter-jersey资源上@Component注解的用途,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32574887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com