Maven Exec Plugin,Spring 和 ojdbc7 组合防止 JVM 关闭

Maven Exec Plugin, Spring and ojdbc7 combination prevents JVM from shutting down

exec-maven-plugin - 1.6.0
Spring - 5.1.5
com.oracle:ojdbc7 - 12.1.0.2

我有一个简单的 Java class,它启动一个 Spring AnnotationConfigApplicationContext,其中包含一个 DriverManagerDataSource(oracle 数据库)。 class 然后在调用 context.close() 方法之前插入几行。

当我从我的 Intellij 运行 class 时,这非常有用。但是,当我通过 exec-maven-plugin 运行 执行此操作时,出现以下错误

[WARNING] thread Thread[oracle.jdbc.driver.BlockSource.ThreadedCachingBlockSource.BlockReleaser,4,MYCLASS] was interrupted but is still alive after waiting at least 14999msecs
[WARNING] thread Thread[oracle.jdbc.driver.BlockSource.ThreadedCachingBlockSource.BlockReleaser,4,MYCLASS] will linger despite being asked to die via interruption
[WARNING] NOTE: 1 thread(s) did not finish despite being asked to  via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[WARNING] Couldn't destroy threadgroup org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=MYCLASS,maxpri=10]

有一些关于 ThreadedCachingBlockSource class 内存泄漏的链接,但没有具体说明我必须做什么。

只有当我通过 exec-maven-plugin 运行 而不是当我说右键单击和 运行 Intellij class

时才会发生这种情况

我试过显式调用 DriverManager.getDriversderegisterDriver 但没有帮助

调试后发现这与 ojdbc 无关,但与 exec maven 插件有关。

https://github.com/camelinaction/camelinaction2/issues/52 中所述,添加 -Dexec.cleanupDaemonThreads=false 解决了问题