遇到依赖问题

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/maven-repository/org/apache/logging/log4j/log4j-slf4j-impl/2.18.0/log4j-slf4j-impl-2.18.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/maven-repository/ch/qos/logback/logback-classic/1.2.12/logback-classic-1.2.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]

查到说是 slf4j包冲突了,各种尝试 引包 不引包 折腾了2个小时
解决不了,折腾下来后 发现 肯定是有依赖引用了 slf4j 这个包
于是点开 项目的 dependencies,发现
Jedis包会依赖
image
Graph包也会依赖
image
image
ges包也会依赖
image
spring启动的时候 还依赖
image

最快速的方法是用 Dependency Analyzer 你搜索下报错的 log4j-slf4j-impl 和 logback-classic 分别属于哪些组件的包 去做处理
logback
image
log4j-slf4j
image

可以给包冲突的地方加上排除,但不做也没关系 maven自己只会引一个

        <dependency>
            <groupId>com.huawei.ges</groupId>
            <artifactId>ges-sdk</artifactId>
            <version>${ges-sdk.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-slf4j-impl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

关键是解决 log4j-slf4j-impl 包 和 logback-classic 冲突的问题
log4j-slf4j-impl
image
image
logback-classic

理所当然 保留Spring的 除去外部依赖 Graph-SDK的
再搜索 log4j-slf4j-impl,已经没有了

再遇问题

An attempt was made to call a method that does not exist. The attempt was made from the following location: org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer$CachingMetadataReaderFactoryPostProcessor.register(SharedMetadataReaderFactoryContextInitializer.java:104)
The following method did not exist: org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition(Ljava/lang/Class;Ljava/util/function/Supplier;)Lorg/springframework/beans/factory/support/BeanDefinitionBuilder;

明明是有SpringBoot 和 spring-beans的 但报错 说没有,删掉之后还是报错,搜下来发现
很有可能是 SpringBoot 与 Spring版本不匹配导致的,于是开始修改

还真是这个问题

        <spring-boot.version>2.6.7</spring-boot.version>
        <spring.version>5.3.20</spring.version>

值得注意的是 spring-context包里是会包含
image
不用去额外引包

当前module要启动 springBoot的话 要自己引用 spring-boot-starter-web包,通过引入其他module 启动不可取

posted on   大元王保保  阅读(21)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类



点击右上角即可分享
微信分享提示