1.昨天在maven build项目中发现有个问题,如下所示
java.lang.NoSuchMethodError: org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;Lorg/springframework/beans/factory/support/BeanDefinitionRegistry;)V at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$1.<init>(AbstractRepositoryConfigurationSourceSupport.java:68) at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.getConfigurationSource(AbstractRepositoryConfigurationSourceSupport.java:67) at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:58) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:352) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:143) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) at com.ppdai.realtime.datachannel.mq.MessageQueueApp.main(MessageQueueApp.java:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:558) at java.lang.Thread.run(Thread.java:748)
原因分析:
https://github.com/spring-projects/spring-boot/commit/5a4ef50ef1d71f1a42edaee309b3e04fb754b13a
因为spring boot和sping-data-redis版本不匹配导致的,spring-data-redis使用 1.8.1.RELEASE版本 依赖
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-keyvalue</artifactId> <version>1.2.1.RELEAS</version>
</dependency>
依赖
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-commons</artifactId> <version>1.13.1.RELEASE</version> </dependency>
如下图所示 这是spring-boot 1.5.9.Release版本的函数
而spring-data-commons中构造函数如下
二种解决方案,
第一 将spring-boot-autoconfig版本从1.5.9.RELEASE降低为1.5.2
或者将spring-data-commons版本从1.13.1.RELEASE升到1.13.7.RELEASE
完结。。
另外附上一个问题
Caused by: java.lang.ClassNotFoundException: org.springframework.data.repository.config.RepositoryConfigurationSource
Caused by: java.lang.ClassNotFoundException: org.springframework.data.repository.config.RepositoryConfigurationSource at java.net.URLClassLoader.findClass (URLClassLoader.java:381) at java.lang.ClassLoader.loadClass (ClassLoader.java:424) at java.lang.ClassLoader.loadClass (ClassLoader.java:357) at java.lang.Class.getDeclaredConstructors0 (Native Method) at java.lang.Class.privateGetDeclaredConstructors (Class.java:2671) at java.lang.Class.getConstructor0 (Class.java:3075) at java.lang.Class.getDeclaredConstructor (Class.java:2178) at org.springframework.beans.BeanUtils.instantiateClass (BeanUtils.java:102) at org.springframework.beans.BeanUtils.instantiateClass (BeanUtils.java:125) at org.springframework.context.annotation.ConfigurationClassParser.processImports (ConfigurationClassParser.java:585) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass (ConfigurationClassParser.java:293) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass (ConfigurationClassParser.java:244) at org.springframework.context.annotation.ConfigurationClassParser.processImports (ConfigurationClassParser.java:595) at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors (ConfigurationClassParser.java:538) at org.springframework.context.annotation.ConfigurationClassParser.parse (ConfigurationClassParser.java:184) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions (ConfigurationClassPostProcessor.java:308) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry (ConfigurationClassPostProcessor.java:228) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors (PostProcessorRegistrationDelegate.java:270) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors (PostProcessorRegistrationDelegate.java:93) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors (AbstractApplicationContext.java:686) at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:524) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh (EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:693) at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:360) at org.springframework.boot.SpringApplication.run (SpringApplication.java:303)
原因
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration]; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/config/RepositoryConfigurationSource
因为spring-boot autoconfig需要RedisRepositoriesAutoConfiguration 这个类找不到,解决方案
添加依赖
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-commons</artifactId> <version>1.13.7.RELEASE</version> </dependency>
因为spring
本文链接:http://task.lmcjl.com/news/19096.html