java - 我的 pom.xml 包含此 maven-formatter-plugin,但未构建。我需要定义格式目标吗?

标签 java maven plugins pom.xml

错误:

Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.8.1:format (default) on project processing-parent:
The parameters 'encoding' for goal net.revelc.code.formatter:formatter-maven-plugin:2.8.1:format are missing or invalid -> [Help 1]

pom.xml 文件:

<build>
    <plugins>
        <plugin>
            <groupId>net.revelc.code.formatter</groupId>
            <artifactId>formatter-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>format</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    ... //more plugins
    </plugins>
<pluginManagement>
    <plugins>
        <plugin>
            <groupId>net.revelc.code.formatter</groupId>
            <artifactId>formatter-maven-plugin</artifactId>
            <version>2.8.1</version>
            <configuration>
                <configFile>${project.basedir}/formatter.xml</configFile>
            </configuration>
        </plugin>
        ... //more plugins
    </plugins>
</pluginManagement>

我按照插件的文档进行操作,但遇到了这个问题。我也将此与一位同事进行了比较,但似乎他的作品和我的作品没有。我还尝试将配置移动到另一个声明,其目标是出现相同的错误。

最佳答案

问题很可能出在 formatter.xml 文件内。
检查第一行,应该是

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

查找encoding 属性。

如果不是这种情况,您可以在配置 block 内指定编码值

<configuration>
    <configFile>${project.basedir}/formatter.xml</configFile>
    <encoding>UTF-8</encoding>
</configuration>

关于java - 我的 pom.xml 包含此 maven-formatter-plugin,但未构建。我需要定义格式目标吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54914128/

相关文章:

Java 进出

java - 在java中逐位读取数字字符串的最佳方法

javascript - jquery.printElement 根本没有响应

javascript - 可以在页面处理之前修改传入数据的 Firefox 插件?

java - Java从数据库中读取特定数据字段

java - Selenium 我无法在字段中发送文本。发送 key 不起作用

maven - jetty-maven-plugin 从 mortbay 到 eclipse HTTPS 设置

java - 使用安装的spark和maven将Spark Scala程序编译成jar文件

java - 使用 <phase> 在 Maven 中串行执行插件

c# - 在 Dynamics CRM C# 插件中检索查找字段的显示值