java - 如何解决 maven-formatter-plugin 的问题?

标签 java spring maven formatter

我在 Windows 系统上构建项目时遇到一些问题。我的项目使用 formatter-maven-plugin 来实现“验证”目标。在将项目推送到 GitHub 之前,我将其格式化并推送。之后,我将其克隆到我的 Windows 计算机上并尝试“mvn clean install”,但我得到:

 Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.9.0:validate (default) on project application: File 'C:\Users\AUser\Desktop\demo\application\src\main\java\com\myapp\Application.java' has not been previously formatted. Please format file and commit before running validation!

在 Linux 中不存在这个问题。这是为什么?在推送 Git 之前,我对它进行了格式化。为什么linux上不存在这个问题?我无法更改格式目标。

<plugin>
                <groupId>net.revelc.code.formatter</groupId>
                <artifactId>formatter-maven-plugin</artifactId>
                <version>2.9.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>validate</goal>
                        </goals>
                        <configuration>
                            <configFile>${project.basedir}/../eclipse/eclipse-formatter.xml</configFile>
                            <encoding>UTF-8</encoding>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

最佳答案

基于official usage documentation :

使用格式目标运行插件。

mvn formatter:format

执行此操作一次后,您应该能够像平常一样运行。

关于java - 如何解决 maven-formatter-plugin 的问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56670074/

相关文章:

maven - 包含 Maven 配置文件时如何在 Spark 中仅运行一个 Scalatest(通过 wildcardSuites)

Spring Cloud Zuul + OAuth 错误 CORS

java - Spring MVC 不会从链接更改区域设置

java - Maven AspectJ 编织 NullPointerException

java - 如何使用不同的javax.servlet-api?

java - 编辑时从 Spring @Valid 中删除一些类属性

java - 如何为 Rhino/Java 6 脚本引擎模拟 DOM

java - 如何使用 Jackson Mixins 将 json 映射到具有不同结构的 java 对象

java - Java 中是否有类或方法可以检查字符串是否为 SQL Server 关键字?

java - 如何修复未通过的 Spring Security Authorization header ?