mvn clean install 抛出错误 - 文件之前未被格式化。请格式化文件并在 运行 验证之前提交

mvn clean install throwing an error - File has not been previously formatted. Please format file and commit before running validation

创建新文件后,我开始收到错误 "Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.8.1:validate File has not been previously formatted. Please format file and commit before running validation"。

知道为什么会出现此错误以及如何修复它吗?

运行

mvn clean validate -P format

已解决问题。

最上面的答案表明调用验证存在问题。如果这一切都设置正确,但您仍然 运行 遇到这个问题,请试试这个。

基于official usage documentation

运行 具有格式目标的插件。

mvn formatter:format

执行一次后,您应该可以 运行 正常。

要解决此问题:“请在 运行 验证之前格式化文件并提交!”

运行 命令下方

mvn process-sources -P format -e

在 运行 这个命令之后使用 mvn clean install