Browse Source

成功运行quartz任务

master
xyiege 3 years ago
parent
commit
0d242eecb7
  1. 61
      src/main/java/cn/chjyj/szwh/controller/GlobalErrorController.java
  2. 2
      src/main/resources/application.properties

61
src/main/java/cn/chjyj/szwh/controller/GlobalErrorController.java

@ -1,61 +0,0 @@
package cn.chjyj.szwh.controller;
import cn.chjyj.szwh.exception.ChException;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 全局异常控制器
*/
@ControllerAdvice
public class GlobalErrorController {
//日志初始化
private static final Log log = LogFactory.getLog(GlobalErrorController.class);
private JSONObject jsonObject=new JSONObject();
/**
* 异常信息输出
* @return
*/
@ExceptionHandler(ChException.class)
@ResponseBody
public JSONObject aisHandler(ChException ex){
log.error("Exception:"+ex);
jsonObject.put("code",500);
jsonObject.put("msg",ex.getMsg());
return jsonObject;
}
/**
* 空指针异常
* @param e
* @return
*/
@ExceptionHandler(value =NullPointerException.class)
@ResponseBody
public JSONObject exceptionHandler(NullPointerException e){
log.error("空指针异常:"+e);
String msg = e.getMessage()==null?"module not found!":e.getMessage();
jsonObject.put("code",500);
jsonObject.put("msg",msg);
return jsonObject;
}
/**
* 常规异常信息
* @param ex
* @return
*/
@ExceptionHandler(value = Exception.class)
@ResponseBody
public JSONObject exceptionHandler(Exception ex){
log.error("异常信息:"+ex);
jsonObject.put("code",500);
jsonObject.put("msg",ex.getMessage());
return jsonObject;
}
}

2
src/main/resources/application.properties

@ -35,5 +35,5 @@ spring.quartz.wait-for-jobs-to-complete-on-shutdown=true
spring.quartz.overwrite-existing-jobs=false
# 属性
spring.quartz.properties.org.quartz.threadPool.threadCount=5
spring.quartz.properties.org.quartz.threadPool.threadProirity=5
spring.quartz.properties.org.quartz.threadPool.threadPriority=5
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
Loading…
Cancel
Save