結合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
提交
取消