NoClassDefFoundError

背景:

spring boot 集成redis Lettuce池化高效客户端配置


问题:NoClassDefFoundError异常处理方式


现场:

o.s.b.SpringApplication [main] [SpringApplication             ][826] - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'XXX': 
Unsatisfied dependency expressed through field 'P-bean'; 
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'P-bean' defined in file [..\util\redis\RedisUtil.class]: Unsatisfied dependency expressed through constructor parameter 0; 
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'P-XXX' defined in class path resource [../util/redis/RedisConfig.class]: 
Unsatisfied dependency expressed through method 'P-XXX' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'redisConnectionFactory' defined in class path resource [../redis/RedisConfig.class]: 
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [org.springframework.data.redis.connection.RedisConnectionFactory]: Factory method 'redisConnectionFactory' threw exception; nested exception is java.lang.BootstrapMethodError: 
java.lang.NoClassDefFoundError: io/lettuce/core/KeyValue
Caused by: java.lang.NoClassDefFoundError: io/lettuce/core/KeyValue
	... 74 common frames omitted
Caused by: java.lang.ClassNotFoundException: io.lettuce.core.KeyValue
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	... 74 common frames omitted


原因分析:

引用依赖版本与服务配置版本不一致导致

此处是redis与redis集群配置版本不一致导致的


解决方案

修改依赖的中间件或者依赖包的版本号,与服务/环境保持一致

你可能感兴趣的:(Error,spring,解决方案,spring,boot)