问题:
最近公司在将配置信息由UCM转到Apollo,因此需要去掉UCM项目的依赖包。在清理过程中,发现项目启动,一直报java.lang.NoClassDefFoundError: com/aliyun/oss/OSSClient错误。
分析:
发现本地是有相关的依赖的。
并且我还手动引用了:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.13</version>
</dependency>
后来,查资料,说是可能jar包冲突导致的。
一次手动排除依赖的包,例如:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
</exclusions>
</dependency>
后来,启动,发现还是报错。 因此,使用命令:mvn dependency:tree 查找项目所有的依赖关系。
D:\code\g2\base\finance\web\alipay-account-web>mvn dependency:tree
[INFO] Scanning for projects...
[WARNING]
省略*****
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ alipay-account-web ---
[INFO] alipay-account-web:alipay-account-web:jar:1.0.0-perf
[INFO] +- external-system-api:external-system-api:jar:1.0.18-perf:compile
[INFO] | +- org.springframework:spring-tx:jar:4.3.29.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-mongodb:jar:1.1.0.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons-core:jar:1.4.0.RELEASE:compile
[INFO] | | \- org.mongodb:mongo-java-driver:jar:2.10.1:compile
[INFO] | +- com.esotericsoftware:kryo:jar:3.0.0:compile
[INFO] | | +- com.esotericsoftware:reflectasm:jar:1.10.0:compile
[INFO] | | | \- org.ow2.asm:asm:jar:4.2:compile
[INFO] | | +- com.esotericsoftware:minlog:jar:1.3.0:compile
[INFO] | | \- org.objenesis:objenesis:jar:2.1:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-databind:jar:2.11.3:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.3:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.11.3:compile
[INFO] +- com.gy.shop.domain:shop-domain-api:jar:1.5.2-perf:compile
[INFO] | \- org.slf4j:slf4j-log4j12:jar:1.7.7:compile
[INFO] +- com.gy.framework:taskcenter-api:jar:1.0.0-perf:compile
[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.7.30:compile
[INFO] | +- org.slf4j:log4j-over-slf4j:jar:1.7.30:compile
[INFO] | +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | \- com.alibaba:fastjson:jar:1.2.75:compile
[INFO] +- com.gy.framework:lib-oss:jar:1.0.8:compile
[INFO] | +- com.aliyun:aliyun-java-sdk-sts:jar:2.1.6:compile
[INFO] | +- com.aliyun:aliyun-java-sdk-core:jar:2.1.7:compile
[INFO] | \- com.aliyun.oss:aliyun-sdk-oss:jar:2.3.0:compile
[INFO] | \- org.jdom:jdom:jar:1.1:compile
[INFO] +- com.gy.finance.service:finance-service-api:jar:1.0.25-perf:compile
[INFO] | \- org.projectlombok:lombok:jar:1.18.12:compile
[INFO] +- com.gy.ebiz:ebiz-tc-api:jar:1.0.77-perf:compile
[INFO] +- com.gy.ebiz:ebiz-ic-api:jar:1.1.12-perf:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] +- org.mybatis:mybatis:jar:3.1.1:compile
[INFO] +- org.mybatis:mybatis-spring:jar:1.1.1:compile
[INFO] | \- org.springframework:spring-jdbc:jar:4.3.29.RELEASE:compile
[INFO] +- org.apache.shiro:shiro-spring:jar:1.7.0:compile
[INFO] | +- org.apache.shiro:shiro-core:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-lang:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-cache:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-crypto-hash:jar:1.7.0:compile
[INFO] | | | \- org.apache.shiro:shiro-crypto-core:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-crypto-cipher:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-config-core:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-config-ogdl:jar:1.7.0:compile
[INFO] | | \- org.apache.shiro:shiro-event:jar:1.7.0:compile
[INFO] | \- org.apache.shiro:shiro-web:jar:1.7.0:compile
[INFO] | \- org.owasp.encoder:encoder:jar:1.2.2:compile
[INFO] +- org.apache.zookeeper:zookeeper:jar:3.4.5:compile
[INFO] | +- log4j:log4j:jar:1.2.15:compile
[INFO] | | +- javax.mail:mail:jar:1.4:compile
[INFO] | | | \- javax.activation:activation:jar:1.1:compile
[INFO] | | +- javax.jms:jms:jar:1.1:compile
[INFO] | | +- com.sun.jdmk:jmxtools:jar:1.2.1:compile
[INFO] | | \- com.sun.jmx:jmxri:jar:1.2.1:compile
[INFO] | +- jline:jline:jar:0.9.94:compile
[INFO] | \- org.jboss.netty:netty:jar:3.2.2.Final:compile
[INFO] +- org.springframework:spring-test:jar:4.3.29.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:4.3.29.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.springframework:spring-context:jar:4.3.29.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.29.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.29.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.3.29.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.3.29.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:4.3.29.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.3.29.RELEASE:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.22:compile
[INFO] +- c3p0:c3p0:jar:0.9.1.2:compile
[INFO] +- opensymphony:sitemesh:jar:2.4.2:runtime
[INFO] +- com.gagu.framework:framework-components-web:jar:1.0.1-SNAPSHOT:compile
[INFO] | \- javax.servlet.jsp:jsp-api:jar:2.2:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- org.apache.commons:commons-lang3:jar:3.10:compile
[INFO] +- org.freemarker:freemarker:jar:2.3.19:compile
[INFO] +- gy.lib:lib-common:jar:2.0.55-perf:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.12:compile
[INFO] | | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.12:compile
[INFO] | +- com.thoughtworks.xstream:xstream:jar:1.4.14:compile
[INFO] | | +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] | | \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] | +- com.google.code.gson:gson:jar:2.8.6:compile
[INFO] | +- com.google.guava:guava:jar:30.0-jre:compile
[INFO] | | +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] | | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] | | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] | | +- org.checkerframework:checker-qual:jar:3.5.0:compile
[INFO] | | +- com.google.errorprone:error_prone_annotations:jar:2.3.4:compile
[INFO] | | \- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] | +- net.sf.dozer:dozer:jar:5.4.0:compile
[INFO] | | \- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] | +- com.fastdfs:fastdfs_client:jar:1.24:compile
[INFO] | +- com.qiniu:qiniu-java-sdk:jar:7.0.0:compile
[INFO] | | \- com.squareup.okhttp:okhttp:jar:2.3.0:compile
[INFO] | | \- com.squareup.okio:okio:jar:1.3.0:compile
[INFO] | +- redis.clients:jedis:jar:3.1.0:compile
[INFO] | | \- org.apache.commons:commons-pool2:jar:2.6.2:compile
[INFO] | +- gy.lib:lib-key:jar:1.0.0:compile
[INFO] | +- com.alibaba:simpleimage:jar:1.2.0:compile
[INFO] | | \- commons-lang:commons-lang:jar:2.4:compile
[INFO] | +- com.sun.media:jai_codec:jar:1.0:compile
[INFO] | \- com.sun.media:jai_core:jar:1.0:compile
[INFO] +- gy.lib:lib-id:jar:1.0.0-perf:compile
[INFO] +- gy.lib:lib-ds:jar:1.0.0:compile
[INFO] | +- commons-io:commons-io:jar:2.0.1:compile
[INFO] | +- com.alibaba:druid:jar:1.1.21:compile
[INFO] | \- com.github.sgroschupf:zkclient:jar:0.1:compile
[INFO] +- gy.lib:lib-api:jar:1.0.0-perf:compile
[INFO] | +- taobao:taobao-sdk-java-auto:jar:3.0:compile
[INFO] | +- taobao:taobao-sdk-java-crm:jar:1.2:compile
[INFO] | +- com.ebay:ebaycalls:jar:1.0.0:compile
[INFO] | +- com.ebay:ebaysdkcore:jar:1.0.0:compile
[INFO] | +- com.ebay:helper:jar:1.0.0:compile
[INFO] | +- xalan:xalan:jar:2.7.2:compile
[INFO] | | \- xalan:serializer:jar:2.7.2:compile
[INFO] | | \- xml-apis:xml-apis:jar:1.3.04:compile
[INFO] | +- commons-codec:commons-codec:jar:1.7:compile
[INFO] | +- org.apache.thrift:libthrift:jar:0.9.0:compile
[INFO] | +- org.apache.axis2:axis2-adb:jar:1.6.2:compile
[INFO] | | \- org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.0.2:compile
[INFO] | +- org.apache.axis2:axis2-kernel:jar:1.6.2:compile
[INFO] | | +- org.apache.ws.commons.axiom:axiom-api:jar:1.2.13:compile
[INFO] | | | +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile
[INFO] | | | +- jaxen:jaxen:jar:1.1.3:compile
[INFO] | | | +- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:compile
[INFO] | | | \- org.apache.james:apache-mime4j-core:jar:0.7.2:compile
[INFO] | | +- org.apache.ws.commons.axiom:axiom-impl:jar:1.2.13:runtime
[INFO] | | | \- org.codehaus.woodstox:wstx-asl:jar:3.2.9:runtime
[INFO] | | +- org.apache.geronimo.specs:geronimo-ws-metadata_2.0_spec:jar:1.1.2:compile
[INFO] | | +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1:compile
[INFO] | | +- commons-fileupload:commons-fileupload:jar:1.2:compile
[INFO] | | +- wsdl4j:wsdl4j:jar:1.6.2:compile
[INFO] | | +- org.apache.ws.commons.schema:XmlSchema:jar:1.4.7:compile
[INFO] | | +- org.apache.neethi:neethi:jar:3.0.2:compile
[INFO] | | +- org.apache.woden:woden-api:jar:1.0M9:compile
[INFO] | | +- org.apache.woden:woden-impl-dom:jar:1.0M9:compile
[INFO] | | | \- org.apache.woden:woden-impl-commons:jar:1.0M9:compile
[INFO] | | \- javax.ws.rs:jsr311-api:jar:1.0:compile
[INFO] | +- org.apache.axis2:axis2-transport-local:jar:1.6.2:compile
[INFO] | +- org.apache.axis2:axis2-transport-http:jar:1.6.2:compile
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.5.13:compile
[INFO] | +- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] | \- net.sf.json-lib:json-lib:jar:jdk15:2.4:compile
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | \- net.sf.ezmorph:ezmorph:jar:1.0.6:compile
[INFO] +- org.apache.poi:poi:jar:3.15:compile
[INFO] | \- org.apache.commons:commons-collections4:jar:4.1:compile
[INFO] +- org.apache.poi:poi-ooxml:jar:3.15:compile
[INFO] | +- org.apache.poi:poi-ooxml-schemas:jar:3.15:compile
[INFO] | \- com.github.virtuald:curvesapi:jar:1.04:compile
[INFO] +- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
[INFO] | \- stax:stax-api:jar:1.0.1:compile
[INFO] +- gy.domain.service:report-service:jar:1.0.0-perf:compile
[INFO] +- gy.domain:service:jar:1.0.80-perf:compile
[INFO] | +- gy.lib:lib-edi:jar:1.0.0:compile
[INFO] | | \- gy.domain.service:mailno-service-core:jar:1.0.0-SNAPSHOT:compile
[INFO] | | \- com.gagu:gagu-ucm-agent:jar:0.0.2:compile
[INFO] | | \- com.gagu:gagu-ucm-core:jar:0.0.2:compile
[INFO] | | +- com.meidusa.venus.commons:venus-common-exception:jar:3.2.12:compile
[INFO] | | | +- com.meidusa.toolkit.commons:toolkit-common-bean:jar:1.3.6:compile
[INFO] | | | | +- ognl:ognl:jar:3.0:compile
[INFO] | | | | \- com.meidusa.toolkit.commons:toolkit-common-util:jar:1.2.4:compile
[INFO] | | | | \- oro:oro:jar:2.0.8:compile
[INFO] | | | \- com.meidusa.venus.commons:venus-common-base:jar:3.2.12:compile
[INFO] | | | +- com.meidusa.toolkit.commons:toolkit-common-runtime:jar:1.3.6:compile
[INFO] | | | | \- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | | +- org.beanshell:bsh:jar:2.0b4:compile
[INFO] | | | \- org.reflections:reflections:jar:0.9.9-RC1:compile
[INFO] | | +- org.apache.curator:curator-framework:jar:4.2.0:compile
[INFO] | | +- org.apache.curator:curator-recipes:jar:2.2.0-incubating:compile
[INFO] | | +- org.apache.curator:curator-test:jar:2.2.0-incubating:compile
[INFO] | | | \- org.apache.commons:commons-math:jar:2.2:compile
[INFO] | | +- org.apache.curator:curator-client:jar:2.2.0-incubating:compile
[INFO] | | +- org.apache.curator:curator-x-discovery:jar:2.2.0-incubating:compile
[INFO] | | \- com.meidusa.toolkit:fastjson:jar:1.3.17:compile
[INFO] | | +- com.meidusa.toolkit:fastmark:jar:1.0.1:compile
[INFO] | | \- asm:asm-all:jar:3.3.1:compile
[INFO] | \- com.googlecode.xmemcached:xmemcached:jar:1.4.3:compile
[INFO] +- com.alibaba:dubbo:jar:2.5.3:compile
[INFO] | \- org.javassist:javassist:jar:3.15.0-GA:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] +- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] +- gy.arch:invoketrace:jar:0.0.11-SNAPSHOT:compile
[INFO] | \- com.aliyun.openservices:aliyun-log:jar:0.6.1:compile
[INFO] | +- commons-validator:commons-validator:jar:1.4.0:compile
[INFO] | | \- commons-digester:commons-digester:jar:1.8:compile
[INFO] | +- com.google.protobuf:protobuf-java:jar:2.4.1:compile
[INFO] | \- net.jpountz.lz4:lz4:jar:1.3.0:compile
[INFO] +- gy.arch:custom_dubbomonitorsdk:jar:0.0.2-SNAPSHOT:compile
[INFO] | +- io.dropwizard.metrics:metrics-core:jar:4.0.5:compile
[INFO] | \- io.dropwizard.metrics:metrics-jvm:jar:4.0.5:compile
[INFO] +- com.gy.admin:admin-service-api:jar:1.1.1-perf:compile
[INFO] +- gy.arch:logbackplus:jar:0.0.1-SNAPSHOT:compile
[INFO] +- com.gy.admin.system.service:admin-system-service-api:jar:1.1.4-perf:compile
[INFO] \- com.ctrip.framework.apollo:apollo-dubbo-client:jar:1.8.6:compile
[INFO] +- com.ctrip.framework.apollo:apollo-client:jar:1.8.6:compile
[INFO] | +- com.google.inject:guice:jar:4.1.0:compile
[INFO] | | +- javax.inject:javax.inject:jar:1:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.17:compile
[INFO] \- com.ctrip.framework.apollo:apollo-core:jar:1.8.6:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.061 s
[INFO] Finished at: 2020-12-18T10:54:24+08:00
[INFO] ------------------------------------------------------------------------
全局搜索,发现已经没有其它的相关引用了。 心想,难道是运行的包有问题?
于是查询idea的发布包位置,打开lib:发现没有httpcore
果断删除该发布包,重新打包。
正常ok! 启动tomcat,报错消失!
注意:httpclient与httpcore是有对应关系的。