2017-08-31 37 views
-2

I' M只是Java休息api Web服務的初學者。我想在我的項目中添加GSON。所以我只是添加了gson jar,在java構建路徑中添加了外部jar選項,並在pom.xml文件中添加了依賴項,但是它顯示了下面的錯誤:項目構建錯誤:不可解析的POM:重複標記:'依賴項'(位置:START_TAG見過...</properties> r n r n t <依賴項> ... @ 55:16)

項目構建錯誤:不可分析的POM:重複標記:依賴關係'(位置:START_TAG見過... \ r \ n \ r \ 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> 

回答

3

您應該添加的所有標籤您不需要在單獨的依賴項標籤下包含每個依賴項。 正確的方法:

`

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

`

+0

非常感謝。它的作品適合我 – Sangeetha

相關問題