SpringBoot之Callable處理異步請求


/**
 * @Classname CallableController
 * @Description TODO
 * @Date 2020/11/22 17:33
 * @Created by XinHai.Ma
 */
@RequestMapping("/callable")
@RestController
public class CallableController {

    @RequestMapping(value = "/create", method = RequestMethod.GET)
    public Callable<Map<String, Object>> createData() throws RuntimeException {
        return new Callable<Map<String, Object>>() {
            @Override
            public Map<String, Object> call() throws Exception {
                Map<String, Object> result = new HashMap<>();
                result.put("code", 200);
                result.put("message", "success");
                return result;
            }
        };
    }

}

 

就這么寫,處理Callable的線程池就不用配置了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM