Maven:不可解析的POM

时间:2016-06-23 09:03:23

标签: java eclipse spring maven

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

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

  

项目构建错误:不可解析的POM   C:\ Users \用户名\开发\春\项目\为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>

eclipse标志着这一行:

enter image description here

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

注意: Maven版本

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

2 个答案:

答案 0 :(得分:4)

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

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

答案 1 :(得分:1)

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

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