问题描述:
- 引入sentinel的相关依赖之后,启动项目服务,发现如下错误
Error: failed to initialize Sentinel CommandCenterLog
java.lang.NoClassDefFoundError: com/alibaba/csp/sentinel/log/LoggerSpiProviderat com.alibaba.csp.sentinel.transport.log.CommandCenterLog.<clinit>(CommandCenterLog.java:36)at com.alibaba.csp.sentinel.transport.command.SimpleHttpCommandCenter$2.run(SimpleHttpCommandCenter.java:104)at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.alibaba.csp.sentinel.log.LoggerSpiProviderat java.net.URLClassLoader.findClass(URLClassLoader.java:381)at java.lang.ClassLoader.loadClass(ClassLoader.java:424)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)at java.lang.ClassLoader.loadClass(ClassLoader.java:357)... 3 more
Exception in thread "Thread-73" java.lang.NoClassDefFoundError: com/alibaba/csp/sentinel/log/Loggerat com.alibaba.csp.sentinel.transport.log.CommandCenterLog.info(CommandCenterLog.java:48)at com.alibaba.csp.sentinel.transport.command.SimpleHttpCommandCenter$2.run(SimpleHttpCommandCenter.java:104)at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.alibaba.csp.sentinel.log.Loggerat java.net.URLClassLoader.findClass(URLClassLoader.java:381)at java.lang.ClassLoader.loadClass(ClassLoader.java:424)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)at java.lang.ClassLoader.loadClass(ClassLoader.java:357)... 3 more
问题解决:
- 在引入sentinel依赖的地方引入下面的依赖
spring-boot-starter-ahas-sentinel-client
即可成功解决!
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId></dependency><dependency><groupId>com.alibaba.csp</groupId><artifactId>spring-boot-starter-ahas-sentinel-client</artifactId><version>1.4.0</version></dependency>