如何解决架包冲突问题

项目启动报错

java.lang.NoClassDefFoundError
在这里插入图片描述

解决方案

输入mvn dependency:tree命令,查看依赖信息

在这里插入代码片
|  +- io.vertx:vertx-core:jar:4.3.5:compile
[INFO] |  |  +- io.netty:netty-common:jar:4.1.85.Final:compile
[INFO] |  |  +- io.netty:netty-transport:jar:4.1.85.Final:compile
[INFO] |  |  +- io.netty:netty-handler:jar:4.1.85.Final:compile
[INFO] |  |  +- io.netty:netty-handler-proxy:jar:4.1.85.Final:compile
[INFO] |  |  |  \- io.netty:netty-codec-socks:jar:4.1.85.Final:compile
[INFO] |  |  +- io.netty:netty-codec-http:jar:4.1.85.Final:compile
[INFO] |  |  +- io.netty:netty-codec-http2:jar:4.1.85.Final:compile
[INFO] |  |  +- io.netty:netty-resolver:jar:4.1.85.Final:compile
[INFO] |  |  \- io.netty:netty-resolver-dns:jar:4.1.85.Final:compile
[INFO] |  |     \- io.netty:netty-codec-dns:jar:4.1.85.Final:compile
[INFO] |  +- io.vertx:vertx-web:jar:4.3.5:compile
[INFO] |  |  +- io.vertx:vertx-web-common:jar:4.3.5:compile
[INFO] |  |  +- io.vertx:vertx-auth-common:jar:4.3.5:compile
[INFO] |  |  \- io.vertx:vertx-bridge-common:jar:4.3.5:compile
[INFO] |  +- io.vertx:vertx-auth-jwt:jar:4.3.5:compile
[INFO] |  +- io.vertx:vertx-web-client:jar:4.3.5:compile
[INFO] |  |  \- io.vertx:vertx-uri-template:jar:4.3.5:compile
[INFO] |  +- io.vertx:vertx-json-schema:jar:4.3.5:compile
[INFO] |  +- io.vertx:vertx-mqtt:jar:4.3.5:compile
[INFO] |  |  \- io.netty:netty-codec-mqtt:jar:4.1.85.Final:compile
[INFO] |  +- io.vertx:vertx-hazelcast:jar:4.3.5:compile
[INFO] |  |  \- com.hazelcast:hazelcast:jar:4.2.5:compile
[INFO] |  +- io.vertx:vertx-codegen:jar:4.3.5:compile
[INFO] |  +- io.vertx:vertx-sql-client-templates:jar:4.3.5:compile
[INFO] |  |  \- io.vertx:vertx-sql-client:jar:4.3.5:compile
[INFO] |  +- io.vertx:vertx-jdbc-client:jar:4.3.5:compile
[INFO] |  |  \- com.mchange:c3p0:jar:0.9.5.5:compile
[INFO] |  |     \- com.mchange:mchange-commons-java:jar:0.2.19:compile
[INFO] |  +- io.vertx:vertx-http-proxy:jar:4.3.5:compile
[INFO] |  +- io.vertx:vertx-micrometer-metrics:jar:4.3.5:compile
[INFO] |  |  +- io.micrometer:micrometer-core:jar:1.9.5:compile
[INFO] |  |  |  \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime
[INFO] |  |  \- org.hdrhistogram:HdrHistogram:jar:2.1.12:compile
[INFO] |  +- io.micrometer:micrometer-registry-prometheus:jar:1.9.5:compile
[INFO] |  |  \- io.prometheus:simpleclient_common:jar:0.15.0:compile
[INFO] |  |     \- io.prometheus:simpleclient:jar:0.15.0:compile
[INFO] |  |        +- io.prometheus:simpleclient_tracer_otel:jar:0.15.0:compile
[INFO] |  |        |  \- io.prometheus:simpleclient_tracer_common:jar:0.15.0:compile
[INFO] |  |        \- io.prometheus:simpleclient_tracer_otel_agent:jar:0.15.0:compile
[INFO] |  +- org.xerial:sqlite-jdbc:jar:3.36.0.3:compile
[INFO] |  +- org.apache.logging.log4j:log4j-api:jar:2.17.2:compile
[INFO] |  +- org.apache.skywalking:apm-toolkit-log4j-2.x:jar:8.12.0:compile
[INFO] |  +- org.apache.skywalking:apm-toolkit-trace:jar:8.12.0:compile
[INFO] |  +- org.apache.logging.log4j:log4j-core:jar:2.17.2:compile
[INFO] |  +- org.slf4j:slf4j-simple:jar:1.7.36:compile
[INFO] |  +- javax.xml.bind:jaxb-api:jar:2.4.0-b180830.0359:compile
[INFO] |  |  \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] |  +- javax.activation:activation:jar:1.1.1:compile
[INFO] |  +- org.glassfish.jaxb:jaxb-runtime:jar:4.0.0:compile
[INFO] |  |  \- org.glassfish.jaxb:jaxb-core:jar:4.0.0:compile
[INFO] |  |     +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0:compile
[INFO] |  |     +- jakarta.activation:jakarta.activation-api:jar:2.1.0:compile
[INFO] |  |     +- org.eclipse.angus:angus-activation:jar:1.0.0:runtime
[INFO] |  |     +- org.glassfish.jaxb:txw2:jar:4.0.0:compile
[INFO] |  |     \- com.sun.istack:istack-commons-runtime:jar:4.1.1:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.13.3:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] |  +- org.jetbrains:annotations:jar:13.0:compile
[INFO] |  +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.85.Final:compile
[INFO] |  |  +- io.netty:netty-transport-native-unix-common:jar:4.1.85.Final:compile
[INFO] |  |  \- io.netty:netty-transport-classes-kqueue:jar:4.1.85.Final:compile
[INFO] |  +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.85.Final:compile
[INFO] |  |  \- io.netty:netty-transport-classes-epoll:jar:4.1.85.Final:compile
[INFO] |  +- com.hazelcast:hazelcast-kubernetes:jar:2.2.3:compile
[INFO] |  \- io.vertx:vertx-mysql-client:jar:4.3.5:compile
[INFO] +- org.apache.plc4x:plc4j-api:jar:0.9.1:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.5:compile
[INFO] \- org.apache.plc4x:plc4j-driver-modbus:jar:0.9.1:compile
[INFO]    +- org.apache.plc4x:plc4j-spi:jar:0.9.1:compile
[INFO]    |  +- io.netty:netty-codec:jar:4.1.67.Final:compile
[INFO]    |  +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO]    |  |  \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO]    |  +- io.vavr:vavr:jar:0.10.4:compile
[INFO]    |  |  \- io.vavr:vavr-match:jar:0.10.4:compile
[INFO]    |  \- com.github.jinahya:bit-io:jar:1.4.3:compile
[INFO]    +- org.apache.plc4x:plc4j-transport-tcp:jar:0.9.1:compile
[INFO]    +- org.apache.plc4x:plc4j-transport-serial:jar:0.9.1:compile
[INFO]    |  \- com.fazecast:jSerialComm:jar:2.7.0:compile
[INFO]    +- org.apache.plc4x:plc4j-transport-raw-socket:jar:0.9.1:compile
[INFO]    |  +- org.apache.plc4x:plc4j-transport-pcap-shared:jar:0.9.1:compile
[INFO]    |  +- org.apache.plc4x:plc4j-utils-raw-sockets:jar:0.9.1:compile
[INFO]    |  |  +- org.pcap4j:pcap4j-core:jar:1.8.2:compile
[INFO]    |  |  |  \- net.java.dev.jna:jna:jar:5.3.1:compile
[INFO]    |  |  \- org.pcap4j:pcap4j-packetfactory-static:jar:1.8.2:runtime
[INFO]    |  \- org.apache.plc4x:plc4j-utils-pcap-shared:jar:0.9.1:compile
[INFO]    \- io.netty:netty-buffer:jar:4.1.67.Final:compile

以上可以看到netty架包有两个版本4.1.85,4.1.67。

解决方案1

<dependency>
            <groupId>org.apache.plc4x</groupId>
            <artifactId>plc4j-driver-modbus</artifactId>
            <version>${plc4j.modebus.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-buffer</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-codec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

解决方案2

若多个架包有冲突,需要一一排除,可以在外指定使用哪个版本的架包。

<dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-buffer</artifactId>
            <version>4.1.85.Final</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec</artifactId>
            <version>4.1.85.Final</version>
        </dependency>

这样项目就可以运行起来了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值