简体   繁体   English

Maven:不可解析的 POM

[英]Maven: non-parseable POM

I have created a maven project and now I need to add dependencies to my dynamic web project .我已经创建了一个maven 项目,现在我需要将依赖项添加到我的dynamic web project中。 So I added the dependencies named in that spring tutorial .所以我添加了spring 教程中命名的依赖项。

Problem: I get the parsing issue:问题:我遇到了解析问题:

Project build error: Non-parseable POM C:\Users\username\Development\Spring\Projects\MyWebService\pom.xml: Duplicated tag: 'build' (position: START_TAG seen...\r\n \r\n \r\n... @60:10)项目构建错误:不可解析的 POM C:\Users\username\Development\Spring\Projects\MyWebService\pom.xml:重复的标签:'build'(位置:看到 START_TAG...\r\n \r\ r\n...@60:10)

My pom.xml looks like that:我的 pom.xml 看起来像这样:

<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>MyWebService</groupId>
    <artifactId>MyWebService</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.5.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
        <repository>
            <id>org.jboss.repository.releases</id>
            <name>JBoss Maven Release Repository</name>
            <url>https://repository.jboss.org/nexus/content/repositories/releases</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>


</project>

eclipse marks that line: eclipse 标记该行:

在此处输入图像描述

Question: Why is it wrong to have multiple repositories in the pom.xml?问题:为什么在 pom.xml 中有多个存储库是错误的?

Note: Maven Version注: Maven版本

Name: EMPEDDED, Details: 3.3.9/1.7.0.20160603-1931 - for Name: WORKSPACE, Details: NOT AVAILABLE [3.0,) 

I'm seeing that in your error you have \\r\\n \\r\\n \\r\\n . 我在你的错误中看到你有\\r\\n \\r\\n \\r\\n

Could you please ensure that your pom.xml is correctly encoded in UTF-8 and not in ANSI ? 您能否确保您的pom.xml以UTF-8正确编码而不是ANSI?

Try changing the latest version of spring boot like below: 尝试更改最新版本的spring boot,如下所示:

<parent>  
    <groupId>org.springframework.boot</groupId>  
    <artifactId>spring-boot-starter-parent</artifactId>  
    <version>2.0.2.RELEASE</version>
</parent>

I had a similar problem, using Eclipse, arising after commenting out a dependency with <.-- and restoring it.我有一个类似的问题,使用 Eclipse,在用 <.-- 注释掉依赖项并恢复它之后出现。 Checked that the encoding is UTF-8.检查编码是否为 UTF-8。 Restored the original POM.恢复了原来的POM。 Updated/Rebuilt project.更新/重建项目。 None of this helped.这些都没有帮助。

What fixed the error: exiting and re-entering Eclipse.什么修复了错误:退出并重新输入 Eclipse。

Thank you, @user1516873, for your suggestion/comment on the question post.谢谢@user1516873,您对问题帖子的建议/评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM