org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gen

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'generateToken': Unsatisfied dependency expressed through field 'redisUtil'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisUtil' defined in file [C:\Mytool\Test\springboot\springboot_demos\meite-shop-parent\meite-shop-common\meite-shop-common-core\target\classes\com\pk\common\core\utils\RedisUtil.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.pk.common.core.utils.RedisUtil] from ClassLoader [sun.misc.Launcher$AppClassLoader@14dad5dc]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
 

遇到这个问题先要冷静,仔细看日记

日记大概意思就是 :redisUtil dependency 有问题........我仔细想了下原来我依赖的common里面redisutil 类用了redis

结果 我这web 项目里面没有添加依赖.....

解决:

我的问题解决: 加入依赖和配置文件


            org.springframework.boot
            spring-boot-starter-data-redis
 
redis:
        host: 地址
        port: 6379
        database: 0
        timeout: 60s  # 数据库连接超时时间,2.0 中该参数的类型为Duration,这里在配置的时候需要指明单位
        # 连接池配置,2.0中直接使用jedis或者lettuce配置连接池
        jedis:
          pool:
            # 最大空闲连接数
            max-idle: 500
            # 最小空闲连接数
            min-idle: 2
            # 等待可用连接的最大时间,负数为不限制
            max-wait:  -1s
            # 最大活跃连接数,负数为不限制
            max-active: -1

Error creating bean 这种错误解决思路:

1.仔细看日记

2, 冷静仔细去找你注入的地方注解是否有 和 你的启动类是否是在utils类的上级,注入一定要在启动类同级或下级才能扫到注解

3,网上找找

 

你可能感兴趣的:(错误,redis,手记,Error,creating,bean)