Error creating bean with name ‘poolconfig’ defined in class path resource [applicationContext-jedis.xml]:
报的错误:
D:\JAVA1\jDK1.8\bin\java.exe “-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.3\lib\idea_rt.jar=55707:C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.3\bin” -Dfile.encoding=UTF-8 -classpath D:\JAVA1\jDK1.8\jre\lib\charsets.jar;D:\JAVA1\jDK1.8\jre\lib\deploy.jar;D:\JAVA1\jDK1.8\jre\lib\ext\access-bridge-64.jar;D:\JAVA1\jDK1.8\jre\lib\ext\cldrdata.jar;D:\JAVA1\jDK1.8\jre\lib\ext\dnsns.jar;D:\JAVA1\jDK1.8\jre\lib\ext\jaccess.jar;D:\JAVA1\jDK1.8\jre\lib\ext\jfxrt.jar;D:\JAVA1\jDK1.8\jre\lib\ext\localedata.jar;D:\JAVA1\jDK1.8\jre\lib\ext\nashorn.jar;D:\JAVA1\jDK1.8\jre\lib\ext\sunec.jar;D:\JAVA1\jDK1.8\jre\lib\ext\sunjce_provider.jar;D:\JAVA1\jDK1.8\jre\lib\ext\sunmscapi.jar;D:\JAVA1\jDK1.8\jre\lib\ext\sunpkcs11.jar;D:\JAVA1\jDK1.8\jre\lib\ext\zipfs.jar;D:\JAVA1\jDK1.8\jre\lib\javaws.jar;D:\JAVA1\jDK1.8\jre\lib\jce.jar;D:\JAVA1\jDK1.8\jre\lib\jfr.jar;D:\JAVA1\jDK1.8\jre\lib\jfxswt.jar;D:\JAVA1\jDK1.8\jre\lib\jsse.jar;D:\JAVA1\jDK1.8\jre\lib\management-agent.jar;D:\JAVA1\jDK1.8\jre\lib\plugin.jar;D:\JAVA1\jDK1.8\jre\lib\resources.jar;D:\JAVA1\jDK1.8\jre\lib\rt.jar;D:\mycode\spring-jedis\target\classes;D:\rep\redis\clients\jedis\3.3.0\jedis-3.3.0.jar;D:\rep\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;D:\rep\org\apache\commons\commons-pool2\2.6.2\commons-pool2-2.6.2.jar;D:\rep\org\springframework\spring-context\5.2.5.RELEASE\spring-context-5.2.5.RELEASE.jar;D:\rep\org\springframework\spring-aop\5.2.5.RELEASE\spring-aop-5.2.5.RELEASE.jar;D:\rep\org\springframework\spring-core\5.2.5.RELEASE\spring-core-5.2.5.RELEASE.jar;D:\rep\org\springframework\spring-jcl\5.2.5.RELEASE\spring-jcl-5.2.5.RELEASE.jar;D:\rep\org\springframework\spring-expression\5.2.5.RELEASE\spring-expression-5.2.5.RELEASE.jar;D:\rep\org\springframework\spring-beans\5.1.3.RELEASE\spring-beans-5.1.3.RELEASE.jar com.hao.Test
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘poolconfig’ defined in class path resource [applicationContext-jedis.xml]: Post-processing of merged bean definition failed; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.forElements(Ljava/util/Collection;Ljava/lang/Class;)Lorg/springframework/beans/factory/annotation/InjectionMetadata;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:144)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:85)
at com.hao.Test.testSpringJedisSingle(Test.java:15)
at com.hao.Test.main(Test.java:9)
Caused by: java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.forElements(Ljava/util/Collection;Ljava/lang/Class;)Lorg/springframework/beans/factory/annotation/InjectionMetadata;
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:452)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:363)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:311)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1044)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:550)
… 12 more
Process finished with exit code 1
<dependencies>
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
</dependencies>
原因是我的spring-context和spring-beans的坐标的版本太高的了换成4.1.3.RELEASE就好了,学习的路上一直再坚持。