结合Spring项目和Jersey我用Spring JPA构建了一个项目,现在我想在我的Jersey项目中使用它。我已将我的SJPA项目添加为我的pom.xml中的依赖项当我使用GET / POST / PUT / DELETE方法时,我想使用我的SJPA中的服务类。使用注释有一种简单的方法吗?或者我必须AnnotationConfigApplicationContext参加每堂课?感觉有点浪费。@Path("/users")@Produces(MediaType.APPLICATION_JSON)@Consumes(MediaType.APPLICATION_JSON)public final class UserResource{
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
private PodcastService service;
@GET
public Response getAllPodcasts() {
context.scan("org.villy.spring.service");
context.refresh();
service= context.getBean(PodcastService.class);
return Response.ok(service.findAll()).build();
}}
添加回答
举报
0/150
提交
取消