在一个XML配置文件中,我有这个bean,它是另一个bean的属性:
<bean class="org.apache.commons.httpclient.HttpClient">
在我的pom.xml中,我添加了这两个依赖项,因为我需要两者:
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
当我在Websphere服务器中部署EAR时,出现此错误:
原因:java.lang.IllegalStateException:无法将属性“ httpClient”的类型“ org.apache.commons.httpclient.HttpClient”的值转换为所需的类型“ org.apache.http.client.HttpClient”:不匹配找到编辑者或转换策略
所以我在pom.xml中添加了
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>org.apache.httpcomponents:httpclient</artifact>
<excludes>
<exclude>org/apache/http/client/HttpClient.class</exclude>
</excludes>
</filter>
</filter>
</configuration>
</execution>
</executions>
</plugin>
编译后,我注意到它完全改变了EAR中嵌入的WAR的结构。我找不到其他解决方案