【问题标题】:maven pom.xml error with configuration in IntelliJIntelliJ中配置的maven pom.xml错误
【发布时间】:2016-07-03 07:48:17
【问题描述】:

这样的pom.xml有问题。

<build>
        <finalName>console</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>

与上面的代码、源代码和目标代码一样,编码标签在 IntelliJ IDEA 中显示为红色。
旧版本中不存在此代码。因为我将这段代码与 GIT 的新版本合并并提交。此代码为新版本代码。

如果我将鼠标悬停在&lt;source&gt;,那么它会显示

此处不允许元素来源。

如果我将鼠标悬停在&lt;target&gt;,那么它会显示

此处不允许元素目标。

如果我将鼠标悬停在&lt;encoding&gt;,那么它会说

此处不允许元素编码。

是否与tomcat7-maven-plugin或其他问题有关? 我所做的只是将此代码粘贴到 pom.xml。

【问题讨论】:

  • 您粘贴的内容完全是错误的,因为 tomcat7-maven-plugin 不包含此类配置选项,而 IntelliJ 告诉您......在documentation you can see the available options etc.
  • 关于这个构建的原始源代码在 eclipse 中。 eclipse和intellij有什么区别
  • 在Eclipse中也是错误的,因为插件不支持这样的选项...但是Eclipse中插件选项的检查不如IntelliJ...

标签: maven configuration tomcat7-maven-plugin


【解决方案1】:

tomcat7-maven-plugin 不支持源、目标、编码标签。

所以这是错误的源代码。

我解决了这个删除配置标签的问题。

【讨论】:

    【解决方案2】:

    可能只支持三个标签,例如:outputDirectory,finalName,attach。

    tomcat7-maven-plugin 不支持源、目标、编码标签。

    如果是主源,生成的 jar 文件将以 finalName 加上“-sources”的值命名。否则,如果它是测试源,它将是 finalName 加上“-test-sources”。它将在指定的 outputDirectory 中生成。 attach 参数指定是否将 java 源附加到项目的工件列表中。

    引用站点:[在此处输入链接描述][1]https://maven.apache.org/plugins/maven-source-plugin/examples/configureplugin.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-26
      • 1970-01-01
      • 2016-10-03
      • 2023-03-26
      • 1970-01-01
      • 2014-04-04
      • 2018-06-23
      相关资源
      最近更新 更多