SpringCloud依赖冲突

SpringCloud子项目引入一个依赖后子项目就起不起来了,idea提示内容如下:

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'jwtTokenEnhancer', defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [com/h3c/tenant/config/ResourceServerConfig.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

Disconnected from the target VM, address: '127.0.0.1:52278', transport: 'socket'

Process finished with exit code 1

网上比较多的解决方案是在配置文件中加入:

spring.main.allow-bean-definition-overriding=true #当遇到同样名字的时候,是否允许覆盖注册

检查了配置文件,发现所有子项目都已经加上这一条了,没用。

引入其他依赖是没什么问题的,所以问题出在这个依赖上。引入的这个依赖是公司自己的包,问了同事,这个包最高是支持jdk1.8,但是我们现在正在写的这个微服务项目用的是java11(x_x)。总不能为这个依赖降项目jdk吧,好在这个包是我们自己的,源码都在我们手上。所以最后决定干掉这个依赖,把需要的工具类源码直接拷到项目里,问题暂时解决了。

但是个人比较纠结的是,jdk是向上兼容的,我们开发环境下的jre版本高于这个包,为什么会产生冲突呢。等找到原因了再更新

猜你喜欢

转载自blog.csdn.net/qq_42026590/article/details/112556978