在Maven pom.xml

时间:2017-04-11 16:14:50

标签: xml maven checkstyle

我正在尝试在我的pom.xml的<reporting>部分中使用最新版本的Checkstyle,但不断收到错误

Malformed POM pom.xml: Unrecognised tag: 'dependencies' (position: START_TAG seen ...</configuration>\n        <dependencies>... @86:23)  @ pom.xml, line 86, column 23 

以下是我的pom.xml的相关部分。第86行是<dependencies>行。

<reporting>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <version>2.17</version>
      <configuration>
        <configLocation>config/checkstyle.xml</configLocation>
      </configuration>
      <dependencies>
        <dependency>
          <groupId>com.puppycrawl.tools</groupId>
          <artifactId>checkstyle</artifactId>
          <version>7.6.1</version>
        </dependency>
      </dependencies>
    </plugin>
  </plugins>
</reporting>

此代码是直接从Maven Checkstyle plugin网站复制的。我做错了什么?

1 个答案:

答案 0 :(得分:0)

使用<dependencies>标记旁边的<reporting>

请参阅以下示例:

<dependencies>
    <dependency>
        <groupId>com.puppycrawl.tools</groupId>
        <artifactId>checkstyle</artifactId>
        <version>7.6.1</version>
    </dependency>
</dependencies>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.17</version>
            <configuration>
                <configLocation>config/checkstyle.xml</configLocation>
            </configuration>
        </plugin>

        <!-- Other plugins -->