项目使用sentinel遇到的问题

springboot版本使用4.1.1会报如下错误,需要把boot的版本降低

java 复制代码
Caused by: java.lang.IllegalStateException: @ConditionalOnMissingBean did not specify a bean using type, name or annotation and the attempt to deduce the bean's type failed
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.validate(OnBeanCondition.java:657) ~[spring-boot-autoconfigure-4.1.1.jar!/:4.1.1]
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.<init>(OnBeanCondition.java:603) ~[spring-boot-autoconfigure-4.1.1.jar!/:4.1.1]
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:147) ~[spring-boot-autoconfigure-4.1.1.jar!/:4.1.1]
	at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-4.1.1.jar!/:4.1.1]
	... 24 common frames omitted
Caused by: org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanTypeDeductionException: Failed to deduce bean type for org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClientAutoConfiguration.simpleDiscoveryProperties
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.deducedBeanTypeForBeanMethod(OnBeanCondition.java:686) ~[spring-boot-autoconfigure-4.1.1.jar!/:4.1.1]
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.deducedBeanType(OnBeanCondition.java:676) ~[spring-boot-autoconfigure-4.1.1.jar!/:4.1.1]
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.<init>(OnBeanCondition.java:596) ~[spring-boot-autoconfigure-4.1.1.jar!/:4.1.1]
	... 26 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClientAutoConfiguration] from ClassLoader [org.springframework.boot.loader.launch.LaunchedClassLoader@28a418fc]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:483) ~[spring-core-7.0.9.jar!/:7.0.9]
	at org.springframework.util.ReflectionUtils.findMethod(ReflectionUtils.java:240) ~[spring-core-7.0.9.jar!/:7.0.9]
	at org.springframework.util.ReflectionUtils.findMethod(ReflectionUtils.java:221) ~[spring-core-7.0.9.jar!/:7.0.9]
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.findBeanMethod(OnBeanCondition.java:715) ~[spring-boot-autoconfigure-4.1.1.jar!/:4.1.1]
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.getMethodReturnType(OnBeanCondition.java:710) ~[spring-boot-autoconfigure-4.1.1.jar!/:4.1.1]
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.getReturnType(OnBeanCondition.java:694) ~[spring-boot-autoconfigure-4.1.1.jar!/:4.1.1]
	at org.springframework.boot.autoconfigure.condition.OnBeanCondition$Spec.deducedBeanTypeForBeanMethod(OnBeanCondition.java:683) ~[spring-boot-autoconfigure-4.1.1.jar!/:4.1.1]
	... 28 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/autoconfigure/web/ServerProperties
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
	at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402) ~[na:na]
	at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504) ~[na:na]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:465) ~[spring-core-7.0.9.jar!/:7.0.9]
	... 34 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.autoconfigure.web.ServerProperties
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:440) ~[na:na]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587) ~[na:na]
	at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.loadClass(JarUrlClassLoader.java:107) ~[spring_demo_sentinel-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
	at org.springframework.boot.loader.launch.LaunchedClassLoader.loadClass(LaunchedClassLoader.java:91) ~[spring_demo_sentinel-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
	... 38 common frames omitted

springboodt项目引入sentinel依赖

<!--sentinel-->

<dependency>

<groupId>com.alibaba.cloud</groupId>

<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>

<version>2022.0.0.0-RC2</version>

</dependency>

springboot的版本使用 3.0.9

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<!-- fixme 版本必须是 3.0.9 配合 spring alibaba的 2022.0.0.0-RC2版本 -->

<version>3.0.9</version>

</parent>

添加控制台配置

复制代码
spring:
  cloud:
    sentinel:
      transport:
        dashboard: localhost:8080  # 配置sentinel控制台地址

启动/部署项目后访问测试

http://8.160.170.126:8081/api/sentinel/hello

sentinel控制台可以看到实时监控了

http:8.160.170.126:8080/#/dashboard/metric/spring_demo_sentinel

相关推荐
秋名RG1 小时前
(二)存储、CPU 与指令执行——程序为什么快,又为什么慢
java·开发语言
BeiGuTing_code2 小时前
Java泛型与Object
java·开发语言
惊讶的猫2 小时前
Tika文档解析
java
HEJOO92 小时前
Java 类加载过程详解:从加载到初始化的完整链路
java·开发语言·firefox
科学熊2 小时前
Java 分布式理论与高并发编程
java·开发语言·分布式
砚底藏山河2 小时前
python量化实操:回测数据缓存与重放
java·python·金融·1024程序员节
学长毕设2 小时前
基于springboot的农资管理系统-附源码
java·spring boot·后端
晒太羊的猫2 小时前
hot100子串
java·算法·leetcode
开开心心就好3 小时前
本地文件搜索工具,双击Ctrl就能呼出搜索
java·服务器·前端·支持向量机·ffmpeg·音视频·模拟退火算法