org.springframework.boot.SpringApplication.reportFailure(SpringApplication.java:858) >>> Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'noticeCacheRedis': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'redis.clients.jedis.JedisPool' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:324) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1395) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
在代码中加入@bean注解
不知道你这个问题是否已经解决, 如果还没有解决的话:解决方法:
修改web.xml,我将关于spring的配置文件都放在了名为spring的文件夹中,如图:
原来:
<context-param>
<param-name>contextConfigLocation</param-name>
<!--指定文件位置 *通配符 -->
<param-value>classpath:spring/*.xml</param-value>
</context-param>
修改后:
<context-param>
<param-name>contextConfigLocation</param-name>
<!--指定文件位置 *通配符 -->
<param-value>classpath:spring/*.xml,classpath:spring/jedis.xml</param-value>
</context-param>
或者(推荐使用):
<context-param>
<param-name>contextConfigLocation</param-name>
<!--指定文件位置 *通配符 -->
<param-value>classpath*:spring/*.xml</param-value>
</context-param>