Java DataAccessException无法捕获
我的代码有DataAccessException,但无法捕获,为什么Java DataAccessException无法捕获,java,spring,Java,Spring,我的代码有DataAccessException,但无法捕获,为什么 CustomerPlan newCust = data.customerPlan; try { this.demandService.doCreateCustomerPlanAndDemandForecast(newCust, newDf); } catch (DataAccessException de) { log.info("de -------------------------
CustomerPlan newCust = data.customerPlan;
try {
this.demandService.doCreateCustomerPlanAndDemandForecast(newCust,
newDf);
} catch (DataAccessException de) {
log.info("de ------------------------------------");
de.printStackTrace();
log.info("de end ------------------------");
} catch (Exception le) {
log.info("de ------------------------------------");
le.printStackTrace();
log.info("de end ------------------------");
} catch (Throwable t) {
log.info("tttttttttttttttttttttttt");
t.printStackTrace();
}
例外情况如下:
at rmes.service.demand.DemandService.doCreateCustomerPlanAndDemandForecast(DemandService.java:132)
这里发生异常,如何捕捉
我的代码有DataAccessException,但无法捕获,为什么
CustomerPlan newCust = data.customerPlan;
try {
this.demandService.doCreateCustomerPlanAndDemandForecast(newCust,
newDf);
} catch (DataAccessException de) {
log.info("de ------------------------------------");
de.printStackTrace();
log.info("de end ------------------------");
} catch (Exception le) {
log.info("de ------------------------------------");
le.printStackTrace();
log.info("de end ------------------------");
} catch (Throwable t) {
log.info("tttttttttttttttttttttttt");
t.printStackTrace();
}
一些可能的解释是:
因为在try/catch中没有抛出异常;i、 它被扔到了别的地方。仔细阅读完整的stacktrace将告诉您这是否属实
因为在不同的包中有多个名为DataAccessException的异常,而您试图捕获错误的异常。仔细阅读完整的stacktrace,您的代码将告诉您这是否正确
因为您设法多次加载DataAccessException。只有当您的应用程序或框架在不同的上下文中使用不同的类加载器链时,才会发生这种情况;e、 g.如果您有多个web应用程序,典型的web容器将执行此操作
你这样评论:
除了这个,什么地方都没有
这可能就是问题所在。如果在这个try/catch的上下文中没有抛出异常,那么这个try/catch将无法捕获它!但是,除非您针对未捕获的异常发布完整的stacktrace,否则我们将无法帮助您解决此问题。除此之外,任何地方都没有捕获。