![](/img/trans.png)
[英]How to prevent 'Retry Policy Exhausted' Exception to be print in console of spring boot?
[英]How not to print exception on console
我實現了自己的自定義異常。 我不希望它在框架控制台上打印異常。 可能嗎?
2017年5月15日2:47:24 PM org.apache.catalina.core.StandardWrapperValve為路徑為[/ project-services]的servlet [project-services]調用SEVERE:Servlet.service()引發異常[請求處理失敗; 嵌套的異常是ba.project.exception.TAException:在選定的日期之間沒有任何巡回活動。]根本原因ba.project.exception.TAException:在ba.project.service的選定的日期之間沒有任何巡回活動。 TAServices.findByTourTypeWithDates(TAServices.java:94)
自訂例外:
public class TAException extends RuntimeException {
private static final long serialVersionUID = 1 L;
public TAException(String msg) {
super(msg);
}
public TAException(String msg, Throwable e) {
super(msg, e);
}
}
這是我引發異常的方法:
public List < Object > findByTourTypeWithDates(String tourType, Date checkin, Date checkout)
throws ParseException, TAException {
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
Date todayDate = dateFormatter.parse(dateFormatter.format(new Date()));
if (checkin.after(todayDate)) {
return taDAO.findByTourTypeWithDates(tourType, checkin, checkout);
}
throw new TAException("There is no any tour activity between selected dates.");
}
看一下Java Exception的規范
https://docs.oracle.com/javase/7/docs/api/java/lang/Exception.html
我認為您要搜索的是writableStackTrace,可以根據需要將其設置為false。 或者,您可以重寫getMessage,以使用您所使用的軟件包或類似內容進行檢入。 這取決於您的確切需求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.