项目构建错误:不可解析的POM:重复的标记:'dependencies'(位置:START_TAG见... \ r \ n \ r \ n \ t <依赖关系> ... @ 55:16)

时间:2017-08-31 05:07:08

标签: maven

我只是java rest api web服务的初学者。我想在我的项目中添加GSON。所以我刚刚在java构建路径中使用add external jar选项添加了gson jar,并在pom.xml文件中添加了依赖项,但它显示了以下错误,

项目构建错误:不可解析的POM:重复的标记:'依赖项'(位置:START_TAG见... \ r \ n \ r \ n \ t ... @ 55:16)

你能否建议我解决这个问题?

这是pom.xml文件,

http://maven.apache.org/maven-v4_0_0.xsd“&GT;

<modelVersion>4.0.0</modelVersion>

<groupId>com.example.feeds</groupId>
<artifactId>RESTfullProject</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>RESTfullProject</name>

<build>
    <finalName>RESTfullProject</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <inherited>true</inherited>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey</groupId>
            <artifactId>jersey-bom</artifactId>
            <version>${jersey.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
        <!-- use the following artifactId if you don't need servlet 2.x compatibility -->
        <!-- artifactId>jersey-container-servlet</artifactId -->
    </dependency>
    <!-- uncomment this to get JSON support <dependency> <groupId>org.glassfish.jersey.media</groupId> 
        <artifactId>jersey-media-moxy</artifactId> </dependency> -->
</dependencies>
<properties>
    <jersey.version>2.16</jersey.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.1</version>
    </dependency>
</dependencies>

1 个答案:

答案 0 :(得分:3)

您应该在单个标记中添加所有标记。您不需要在单独的依赖项标记下包含每个依赖项。 正确的方法:

`

<dependencies>
<dependency1>
</dependency1>
<dependency2>
</dependency2>
</dependencies>

`