我只是Java Rest API Web服务的初学者。我想在我的项目中添加GSON。因此,我刚刚在Java构建路径中使用添加外部JAR选项添加了GSON JAR,并在pom.xml文件中添加了依赖项,但是它显示了以下错误,
项目构建错误:不可避免的POM:重复的标签:'依赖项'(位置:start_tag看到... r r n r r n n t ... @55:16)
您能建议我一个解决这个问题的想法吗?
这是pom.xml文件,
http://maven.apache.org/maven-v4_0_0.xsd">
<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>
您应该在单个<dependencies>
标签中添加所有<dependency>
标签。您无需在单独的依赖项标签下包括每个依赖项。
正确的方式:
<dependencies>
<dependency1>
</dependency1>
<dependency2>
</dependency2>
</dependencies>