我在Spring中有一个会话范围的bean(Ama04Service),它在web上下文中设置。我有一个以Callable运行的任务,我需要从jersey web服务访问这个bean。我该怎么做到这一点?如果我只是尝试自动装配bean,首先调用Ama04ServiceImpl(公共响应verifNum),自动装配成功运行,那么如果我在泽西网络服务(Ama_04Service)中调用另一个方法(clickReponse),我会得到NullPointerException 这看起来像sprine重新实例化autowired bean 请问任何想法? 提前谢谢。
我注入的会话范围的bean看起来像这样:
Service("ama04Service")
@Scope(value="session", proxyMode=ScopedProxyMode.TARGET_CLASS)
@Transactional(readOnly = false)
public class Ama04ServiceImpl implements Ama04Service, LineListener {
////some code here//////
}
调用会话范围的bean的jersey web服务看起来像这样
@Path("/ama04")
public class Ama_04Service {
@Autowired
Ama04Service ama04Service;
@Autowired
Ama01Service ama01Service;
@Autowired
Ama03Service ama03Service;
@Autowired
ResourceBundleService resourceBundleService;
@GET
@Path("/quest/{date}/{numDonn}/{language}")
@Produces(MediaType.APPLICATION_JSON)
public Response verifNum(@PathParam("numDonn") final String numDonn,
@PathParam("date") final String date,
@PathParam("language") final String language) {
///////// some code here///////
@GET
@Path("/clickRepons/{numDonn}/{occRep}/{occ}/{date}/{language}")
@Produces("application/json; charset=UTF-8")
public String clickReponse(@PathParam("numDonn") final String numDonn,
@PathParam("occRep") int occRep, @PathParam("occ") int occ,
@PathParam("date") final String date,
@PathParam("language") final String language) {
Ama4 currentAma = new Ama4();
}