使用 exec-maven-plugin 在文件更改时重新运行应用程序

问题描述

我有一个基于 maven 的应用程序,我使用 exec-maven-plugin 与 mvn compile exec:java 一起运行。如何配置它以便在检测到文件更改时重新启动应用程序?

解决方法

如果 maven-compiler-plugin:compile 编译更改的源代码,它会创建文件 .../target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst

您可以将您的 exec-maven-plugin 放入 Maven profile 并通过 <file>/<exists> 激活它。