简体   繁体   English

Spring Boot Maven插件缺少堆栈跟踪

[英]Spring Boot Maven Plugin missing stack trace

I recently updated a code base from Spring Boot 1.2.7 to v2.0.0. 我最近将代码库从Spring Boot 1.2.7更新到了v2.0.0。 For the most part, this was successful but I noticed an undesired change in functionality wherein stack traces are missing when failures occur during startup. 在大多数情况下,这是成功的,但我注意到功能上的意外更改,其中在启动过程中发生故障时,缺少堆栈跟踪。 I am uncertain whether I missed something, this is intended, or if a bug was introduced between these two versions. 我不确定是否错过了某些东西,这是有意的,还是在这两个版本之间引入了错误。

The project uses the Spring Boot Maven Plugin. 该项目使用Spring Boot Maven插件。 When JVM arguments are included and if the app fails to start (possibly due to incorrect Spring wiring, port already in use, etc.), a stack trace will not be logged to explain why the app failed to start. 当包含JVM参数并且如果应用程序无法启动(可能是由于不正确的Spring接线,端口已在使用等)而导致的,则不会记录堆栈跟踪信息以说明应用程序无法启动的原因。 If the JVM arguments are omitted, the stack trace will be included in the logs. 如果省略JVM参数,则堆栈跟踪将包含在日志中。 Prior to the upgrade, the stack trace was included when JVM arguments were used. 升级之前,使用JVM参数时将包括堆栈跟踪。

As the plugin forks the JVM when JVM arguments are included and the application is not otherwise forking the JVM, I wonder if it has something to do with that. 当插件包含JVM参数并且应用程序没有以其他方式派生JVM时,该插件会分叉JVM,我想知道它是否与此有关。

To help with this issue, I started to pull together a stripped-down version of the POM as well as a "main" class. 为了解决这个问题,我开始将POM的精简版本和“主”类放在一起。 While the project is using Logback for logging, during the process of creating a simplified version I found that Log4J was transitively included via several other libraries. 当项目使用Logback进行日志记录时,在创建简化版本的过程中,我发现通过其他几个库可传递地包含了Log4J。 When I removed the Log4J dependencies from the classpath, logging during startup worked as expected. 当我从类路径中删除Log4J依赖项时,启动过程中的日志记录按预期工作。

The inclusion of Log4J in the project pre-dates the upgrade of Spring Boot version. 在项目中包含Log4J的日期早于Spring Boot版本的升级。 So, there is certainly a missing piece here as I don't know what changed to cause the breakage. 因此,这里肯定缺少一块,因为我不知道发生了什么变化而导致断裂。 However, the path forward seems clear as Log4J should not be included in the project. 但是,前进的道路似乎很明确,因为Log4J不应该包含在项目中。 I will be happy to accept any other answers with more information on what may have changed to cause the differing behavior but, if not, I will consider this resolved. 我将很乐意接受任何其他答案,并提供更多有关可能更改为导致不同行为的信息,但是,如果没有,我将认为已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM