2017-06-19 105 views
0

我有這個POM文件,它有一堆依賴關係。Maven不能提取依賴關係

<?xml version="1.0" encoding="UTF-8"?> 
<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>com.mydevgeek</groupId> 
    <artifactId>rest-template-service</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>rest-template-service</name> 
    <description>Demo Rest Template Service</description> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.5.3.RELEASE</version> 
     <relativePath /> <!-- lookup parent from repository --> 
    </parent> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
     <java.version>1.8</java.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>httpclient</artifactId> 
      <version>4.5</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.fasterxml.jackson.core</groupId> 
      <artifactId>jackson-core</artifactId> 
      <version>2.8.7</version> 
     </dependency> 
     <dependency> 
      <groupId>com.fasterxml.jackson.core</groupId> 
      <artifactId>jackson-databind</artifactId> 
      <version>2.8.7</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 


</project> 

在我的源代碼,我有一類與一羣進口

import com.fasterxml.jackson.databind.ObjectMapper; 
import org.apache.commons.httpclient.HttpClient; 
import org.apache.commons.httpclient.methods.PostMethod; 
import org.apache.commons.httpclient.methods.RequestEntity; 
import org.apache.commons.httpclient.methods.StringRequestEntity; 

import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.http.HttpEntity; 
import org.springframework.http.HttpHeaders; 

出於某種原因,當我運行mvn乾淨安裝,試圖導入HttpClient的代碼時,我得到的錯誤。所有其他進口工作正常。

package org.apache.commons.httpclient does not exist 

我檢查了我的.m2存儲庫,並在那裏看到httpclient jar。我嘗試刪除它,並再次下載,以確保它沒有損壞,這沒有幫助。

對此提出建議?

+0

Onces刪除.m2文件夾中的.jar重新下載它 –

回答

2

Appache HttpClient v.4.5沒有這樣的包。

它採用org.apache.http.

所以,你應該改變你的進口報關單或使用圖書館的舊版本。

請參閱here如何遷移到新版本。