سؤال

I've added code to implement a RestTemplate Client to my Spring MVC project (Eclipse, Maven, Spring 3.1.0.RELEASE). Everything builds and when I launch to Tomcat7, I get the output below. Is it possibly a Spring artifact I'm missing in the pom.xml? I've got

  • spring-webmvc (excluding commons-logging)
  • spring-oxm
  • spring-security-web
  • spring-security-config
  • spring-tx
  • spring-aop
  • spring-orm
  • spring-test
  • apache httpclient (excluding commons-logging).

org.springframework.beans.factory.BeanCreationException: Error creating bean . . nested exception is java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials

Caused by: java.lang.ClassNotFoundException: org.apache.http.auth.Credentials
at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1521)
... 39 more

هل كانت مفيدة؟

المحلول

You need apache http components:

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
     <version>4.1.1</version>
</dependency>
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpcore</artifactId>
    <version>4.1.1</version>
</dependency>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top