【问题标题】:Invalid content was found starting with element '{"http://maven.apache.org/POM/4.0.0":plugins}'发现以元素'{"http://maven.apache.org/POM/4.0.0":plugins}' 开头的无效内容
【发布时间】:2021-01-20 12:44:39
【问题描述】:

我在尝试配置 pom xml 以开始构建项目时遇到此错误,但我不知道如何修复。我很努力,删除和添加字符,但我没有成功。 看来,问题出在“插件”上。

有人给点小费吗?

提前谢谢你!

这是我的 pom 文件:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.Dev2021</groupId>
    <artifactId>aula-configurando-o-spring-framework</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>aula-configurando-o-spring-framework</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.2.7.RELEASE</version>
        </dependency>
    </dependencies>

    <build/>
        <plugins/>
            <plugin/>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.3</version>
                <configuration/>
                    <source>1.14</source>
                    <target>1.14</target>
                <configuration/>
             <plugin/>
        <plugins/>
    <build/>
</project>

【问题讨论】:

  • 检查所有带有斜线的开始和结束标签。示例:开头&lt;build/&gt; 应为&lt;build&gt;,结尾&lt;build/&gt; 应为&lt;/build&gt;。此外,Java 14 是 14 而不是 1.14。这些类型的问题应该会为您提供具体和相关的错误消息 - 所以还有其他事情发生。
  • 谢谢! @andrewjames。我试过了,但仍然有错误。编译器需要一些我不知道它是什么的东西。 spring context 和 maven 的版本变“红色”,表示有问题。

标签: java maven plugins pom.xml


【解决方案1】:

欢迎来到 SO。只需将部分替换为以下内容

     <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.3</version>
                <configuration/>
                    <release>14</release> 
                <configuration/>
             </plugin>
        </plugins>
    </build>

在差异编辑器中将其与您之前的代码进行比较,并阅读 andrewjames 的评论。您将能够处理以前的错误。

【讨论】:

  • 您的解决方案使用 1.14 作为 Java 版本 - 这是无效的。
  • 谢谢@Karthick。错误仍然存​​在。我试过你说的,现在版本有问题。新错误:java:error: release version 5 not supported。我在这个网站上选择了一个解决方案,但还没有工作。 dev.to/techgirl1908/…
  • 我已经更新了我的答案。请尝试一下并告诉我们。确实,这正是@andrewjames 所指出的。
  • 大家好,很抱歉之前没有回答。我添加了依赖项,一切正常。谢谢大家。
猜你喜欢
  • 2021-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-18
  • 2016-01-22
相关资源
最近更新 更多