【问题标题】:Using <dependencies> tag within <reporting> in Maven pom.xml在 Maven pom.xml 中的 <reporting> 中使用 <dependencies> 标记
【发布时间】:2017-09-07 03:41:16
【问题描述】:

我正在尝试在我的 pom.xml 的 &lt;reporting&gt; 部分中使用最新版本的 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 行是&lt;dependencies&gt; 行。

<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 网站复制而来。我做错了什么?

【问题讨论】:

    标签: xml maven checkstyle


    【解决方案1】:

    &lt;reporting&gt; 标签之外使用&lt;dependencies&gt;

    请看下面的例子:

    <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 -->
    

    【讨论】:

      【解决方案2】:

      报告插件(例如 Checkstyle)是特殊类型的插件,可以在 reportingbuild 部分进行配置。根据我们进行配置的位置,可能会有一些限制。

      当我们在报告部分配置报告插件时,我们不能使用 executiondependency 标签,但是当我们在构建部分定义插件时允许使用这些标签.

      这个问题的问题是依赖定义在错误的地方(在报告部分内)。

      【讨论】:

        猜你喜欢
        • 2013-10-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-03
        • 2013-07-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多