【问题标题】:Maven: non-parseable POMMaven:不可解析的 POM
【发布时间】:2016-10-25 12:16:57
【问题描述】:

我创建了一个maven project,现在我需要将依赖项添加到我的dynamic web project。 所以我添加了以spring tutorial命名的依赖项。

问题:我遇到了解析问题:

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

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

日食标记那条线:

问题:为什么在 pom.xml 中有多个存储库是错误的?

注意: Maven 版本

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

【问题讨论】:

  • 您的 pom.xml 格式正确,可能是 eclipse 错误?尝试重新启动它,清理缓存等。
  • repositories 元素是继承的,因此您通常会通过在继承链的顶部定义 repositories 元素来指定用于一组项目的存储库。我猜你已经在你的继承链中声明了这个存储库:检查你的其他 pom
  • @Zeromus 谢谢你的提示。我有另一个项目使用一些弹簧依赖项,但它不继承存储库。我怎样才能实现只为当前项目继承该存储库?
  • 你在 Eclipse 中使用什么版本的 Maven?
  • 名称:EMPEDDED,详细信息:3.3.9/1.7.0.20160603-1931 - 名称:WORKSPACE,详细信息:不可用 [3.0,)

标签: java eclipse spring maven


【解决方案1】:

尝试更改最新版本的 spring boot,如下所示:

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

【讨论】:

    【解决方案2】:

    我看到你的错误中有\r\n \r\n \r\n

    能否确保您的pom.xml 正确编码为 UTF-8 而不是 ANSI?

    【讨论】:

    • 好的,有问题了。该文件是没有 BOM 的 UTF-8。把它转换成 UTF-8 就行了
    猜你喜欢
    • 2011-11-28
    • 2021-11-16
    • 2023-03-05
    • 2019-08-14
    • 2013-11-14
    • 2020-04-18
    • 2020-04-24
    • 1970-01-01
    • 2022-11-24
    相关资源
    最近更新 更多