【Java遇错】Error: failed to initialize Sentinel CommandCenterLog

问题描述:

  • 引入sentinel的相关依赖之后,启动项目服务,发现如下错误
    【Java遇错】Error: failed to initialize Sentinel CommandCenterLog_第1张图片
Error: failed to initialize Sentinel CommandCenterLog
java.lang.NoClassDefFoundError: com/alibaba/csp/sentinel/log/LoggerSpiProvider
	at 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.LoggerSpiProvider
	at 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/Logger
	at 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.Logger
	at 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.cloudgroupId>
     <artifactId>spring-cloud-starter-alibaba-sentinelartifactId>
 dependency>
 <dependency>
     <groupId>com.alibaba.cspgroupId>
     <artifactId>spring-boot-starter-ahas-sentinel-clientartifactId>
     <version>1.4.0version>
 dependency>

你可能感兴趣的:(Java遇错合集,java,sentinel,开发语言)