我是靠谱客的博主 紧张秋天,最近开发中收集的这篇文章主要介绍sentinel整合knife4j出现冲突问题解决,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

当整合sentinel时候出现报错

    
.
____
_
__ _ _
/\ / ___'_ __ _ _(_)_ __
__ _    
( ( )___ | '_ | '_| | '_ / _` |    
\/
___)| |_)| | | | | || (_| |
) ) ) )
'
|____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::
(v2.3.9.RELEASE)
2023-01-13 09:54:53.198
INFO 17124 --- [
main] com.swagger.SwaggerApplication
: No active profile set, falling back to default profiles: default
2023-01-13 09:54:53.853
INFO 17124 --- [
main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2023-01-13 09:54:53.853
INFO 17124 --- [
main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2023-01-13 09:54:53.869
INFO 17124 --- [
main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 6ms. Found 0 Redis repository interfaces.
2023-01-13 09:54:54.026
INFO 17124 --- [
main] o.s.cloud.context.scope.GenericScope
: BeanFactory id=f615d333-abc3-32a9-b0ae-91c2a13972c9
2023-01-13 09:54:54.182
WARN 17124 --- [
main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration': Unsatisfied dependency expressed through field 'properties'; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.cloud.sentinel-com.alibaba.cloud.sentinel.SentinelProperties': Could not bind properties to 'SentinelProperties' : prefix=spring.cloud.sentinel, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is javax.validation.NoProviderFoundException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
2023-01-13 09:54:54.182
INFO 17124 --- [
main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-01-13 09:54:54.182 ERROR 17124 --- [
main] o.s.b.d.LoggingFailureAnalysisReporter
:
***************************
APPLICATION FAILED TO START
***************************
Description:
The Bean Validation API is on the classpath but no implementation could be found
Action:
Add an implementation, such as Hibernate Validator, to the classpath
进程已结束,退出代码1

其中有一个报错是因为和knife4j出现的冲突

2023-01-13 09:54:54.182
WARN 17124 --- [
main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration': Unsatisfied dependency expressed through field 'properties'; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.cloud.sentinel-com.alibaba.cloud.sentinel.SentinelProperties': Could not bind properties to 'SentinelProperties' : prefix=spring.cloud.sentinel, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is javax.validation.NoProviderFoundException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.

做法就是在导入knif4j坐标时候排除validation-api依赖

<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.3</version>
<exclusions>
<exclusion>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</exclusion>
</exclusions>
</dependency>

然后再导入sentinel的maven坐标,启动项目就可以了

最后

以上就是紧张秋天为你收集整理的sentinel整合knife4j出现冲突问题解决的全部内容,希望文章能够帮你解决sentinel整合knife4j出现冲突问题解决所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(49)

评论列表共有 0 条评论

立即
投稿
返回
顶部