Exception springboot启动失败,但未打印异常日志?为什么?
SpringApplication.run(DemoApp.class,args)发生了异常,但它没有打印日志。为什么?(我可以让它运行,但为什么没有日志) 这是我调试时复制的异常Exception springboot启动失败,但未打印异常日志?为什么?,exception,spring-boot,Exception,Spring Boot,SpringApplication.run(DemoApp.class,args)发生了异常,但它没有打印日志。为什么?(我可以让它运行,但为什么没有日志) 这是我调试时复制的异常 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0' defined in class p
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0' defined in class path resource [dao/spring-dao.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [dao/spring-dao.xml]: Cannot create inner bean 'com.github.pagehelper.PageHelper#654c1a54' of type [com.github.pagehelper.PageHelper] while setting bean property 'plugins' with key [0]; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.github.pagehelper.PageHelper] for bean with name 'com.github.pagehelper.PageHelper#654c1a54' defined in class path resource [dao/spring-dao.xml]; nested exception is java.lang.ClassNotFoundException: com.github.pagehelper.PageHelper
下面是源代码的位置
public ConfigurableApplicationContext run(String... args) {
try{
......
}catch (Throwable ex) {
handleRunFailure(context, listeners, analyzers, ex);-------//stuck in here
throw new IllegalStateException(ex);
}
}
private void handleRunFailure(ConfigurableApplicationContext context,SpringApplicationRunListeners listeners, FailureAnalyzers analyzers,Throwable exception) {
try {
......
}catch (Exception ex) {
logger.warn("Unable to close ApplicationContext", ex);
}
ReflectionUtils.rethrowRuntimeException(exception);-------//stuck in here
}
public static void rethrowRuntimeException(Throwable ex) {
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex; --------//stuck in here and then all stopped
}
if (ex instanceof Error) {
throw (Error) ex;
}
throw new UndeclaredThrowableException(ex);
}
我的项目集成了一个rpc框架dubbo,它就是这样发生的。我启动了一个新项目,它运行得很好。日志显示:
嵌套异常是java.lang.ClassNotFoundException:com.github.pagehelper.pagehelper
,当在cp上找不到类时,您通常会做什么?当我尝试捕获“SpringApplication.run(DemoApp.class,args)”和e.printStackTrace()时,它可以打印日志。为什么这个方法(运行)是这样设计的------它可以抛出异常,而不需要尝试catch???@SagarRohankar如果它抛出异常,我必须尝试catch,我将不必调试以查看错误!为什么要这样设计?为什么要捕获启动异常?Jsut让它们被抛出,它将被记录。。。例外就在你面前。您的运行时类路径没有必需的类。@DarrenForsyth它被抛出,但从未被记录,除非我尝试捕获,否则我看不到堆栈跟踪