我註釋一個Thread類如下:春天JPA主題:拋出:IllegalArgumentException異常
@Transactional(propagation = Propagation.REQUIRED)
@Component
@Scope("prototype")
public class ThreadRetrieveStockInfoEuronext implements Runnable {
...
}
線程通過Global.poolMultiple.execute(threadRetrieveStockInfoEuronext)連線到控制器類,並呼籲;
public class RetrievelController {
@Autowired
private ThreadRetrieveStockInfoEuronext threadRetrieveStockInfoEuronext;
@RequestMapping(value = "/.retrieveStockInfo.htm", method = RequestMethod.POST)
public ModelAndView submitRetrieveStockInfo(@ModelAttribute("retrieveStockInfoCommand") RetrieveStockInfoCommand command, BindingResult result, HttpServletRequest request) throws Exception {
Global.poolMultiple.execute(threadRetrieveStockInfoEuronext);
return new ModelAndView(".retrieveStockInfo", "retrieveStockInfoCommand", command);
}
全球類:
@SuppressWarnings("unchecked")
@Component
public class Global {
// create ExecutorService to manage threads
public static ExecutorService poolMultiple = Executors.newFixedThreadPool(10);
public static ExecutorService poolSingle = Executors.newFixedThreadPool(1);
...
}
運行應用程序時,會出現以下異常:
java.lang.IllegalArgumentException異常:無法設置 com.chartinvest.admin。 thread.ThreadRetrieveStockInfoEuronext場
com.chartinvest.controller.RetrievelContr oller.threadRetrieveStockInfoEuronext 到com.sun.proxy。$ Proxy52
非常感謝JB爲您的意見,該解決方案完美無缺! – user2023141