2016-04-05 3 views
0

Ich versuche, ein benutzerdefiniertes Spring XD (v1.3.1) -Modul zu erstellen und einige Spring Boot Starter-Projekte zu verwenden, aber ich arbeite gerade in einen Fehler mit Redis.Fehler bei der Redis-Autokonfiguration mit Spring Boot 1.3.3 und Spring XD 1.3.1

Ich habe ein sehr einfaches Beispielprojekt hier: https://github.com/fgreg/redis-error-example, das den Fehler reproduziert. Ich denke, es hat mit der Version von Spring Boot zu tun, die ich benutze.

Grundsätzlich, wenn ich versuche, den Integrationstest auszuführen; Frühling XD schlägt mit dem Fehler zu starten:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration$RedisConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.data.redis.connection.RedisConnectionFactory]: : Error creating bean with name 'org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration$RedisPooledConnectionConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.springframework.boot.autoconfigure.data.redis.RedisProperties org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration$AbstractRedisConfiguration.properties; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.autoconfigure.data.redis.RedisProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration$RedisPooledConnectionConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.springframework.boot.autoconfigure.data.redis.RedisProperties org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration$AbstractRedisConfiguration.properties; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.autoconfigure.data.redis.RedisProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 

    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) 
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:464) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) 
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139) 
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:129) 
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:129) 
    at org.springframework.xd.dirt.server.singlenode.SingleNodeApplication.run(SingleNodeApplication.java:83) 
    at com.example.UpperCaseProcessorIntegrationTest.setUp(UpperCaseProcessorIntegrationTest.java:34) 
    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:497) 
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137) 
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119) 
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42) 
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) 
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) 
    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:497) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration$RedisPooledConnectionConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.springframework.boot.autoconfigure.data.redis.RedisProperties org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration$AbstractRedisConfiguration.properties; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.autoconfigure.data.redis.RedisProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) 
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813) 
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) 
    ... 38 more 
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.springframework.boot.autoconfigure.data.redis.RedisProperties org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration$AbstractRedisConfiguration.properties; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.autoconfigure.data.redis.RedisProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) 
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) 
    ... 59 more 
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.autoconfigure.data.redis.RedisProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) 
    ... 61 more 

Wenn ich jedoch auf die Version herabzustufen zurück

"org.springframework.boot:spring-boot-starter-integration:1.2.3.RELEASE" 

in meinem build.gradle, funktioniert alles einwandfrei.

Ich schaute durch den Spring Boot 1.3 release notes und das einzige, was mir heraus sprang war die neue Unterstützung für die automatische Konfiguration des Caching (einschließlich Redis).

Ich nehme an, dass Spring Boot diese Klassen auf dem Klassenpfad findet und versucht, Redis zu konfigurieren, da Spring XD Redis für Analysen verwendet. Wie bekomme ich es, damit aufzuhören? Oder alternativ, laden Sie korrekt die Redis-Konfiguration, die in der application.yaml Datei innerhalb spring-xd-dirt-1.3.1.RELEASE.jar ist, die auf meinem Classpath ist?

Ich habe die folgenden ohne Erfolg versucht:

  • @EnableAutoConfiguration(exclude = RedisAutoConfiguration.class) meiner IntegrationConfiguration Klasse hinzufügen. Ich denke, es schlägt fehl, bevor ich sogar meine Konfigurationsklasse berücksichtigt habe.
  • Ohne das spring-boot-autoconfigure Modul aus meinen Abhängigkeiten. Dies verursacht nur alle möglichen anderen Fehler.
  • Ich könnte versuchen, mit der spring.autoconfigure.excludes-Eigenschaft, aber ich weiß nicht, wo, wo es tatsächlich funktioniert. Ich kann es nicht als Argument an new SingleNodeApplication().run() übergeben (es scheitert als eine unbekannte Option) und es wird nicht abgeholt, wenn ich es in die Datei spring-module.properties platziere. Darüber hinaus möchte ich dieses Argument nicht als Startup-Argument festlegen müssen, wenn ich schließlich dazu übergehe, dieses benutzerdefinierte Modul bereitzustellen. Ich möchte, dass das Modul eigenständig ist.

Edit: Einige zusätzliche Informationen. Für mein echtes Projekt möchte ich Spring Boot 1.3 wegen der added support for Cassandra verwenden.

Antwort

0

Ich nahm einen härteren Blick auf meinen Abhängigkeiten und ich bemerkte:

compile - Compile classpath for source set 'main'. 
+--- org.springframework.boot:spring-boot-starter-integration:1.3.3.RELEASE 
| +--- org.springframework.boot:spring-boot-starter:1.3.3.RELEASE 
| | +--- org.springframework.boot:spring-boot:1.3.3.RELEASE 
| | | +--- org.springframework:spring-core:4.2.5.RELEASE 
| | | | \--- commons-logging:commons-logging:1.2 
| | | \--- org.springframework:spring-context:4.2.5.RELEASE 
| | |   +--- org.springframework:spring-aop:4.2.5.RELEASE 
| | |   | +--- aopalliance:aopalliance:1.0 
| | |   | +--- org.springframework:spring-beans:4.2.5.RELEASE 
| | |   | | \--- org.springframework:spring-core:4.2.5.RELEASE (*) 
| | |   | \--- org.springframework:spring-core:4.2.5.RELEASE (*) 
| | |   +--- org.springframework:spring-beans:4.2.5.RELEASE (*) 
| | |   +--- org.springframework:spring-core:4.2.5.RELEASE (*) 
| | |   \--- org.springframework:spring-expression:4.2.5.RELEASE 
| | |    \--- org.springframework:spring-core:4.2.5.RELEASE (*) 
| | +--- org.springframework.boot:spring-boot-autoconfigure:1.3.3.RELEASE <------- 
| | | \--- org.springframework.boot:spring-boot:1.3.3.RELEASE (*)    | 
                         | 
                   notice the 1.3.3 here---- 
... 


provided 
\--- org.springframework.xd:spring-xd-dirt:1.3.1.RELEASE 
    ... 
    +--- org.springframework.boot:spring-boot-autoconfigure:1.2.3.RELEASE <----------- 
    | +--- org.springframework.boot:spring-boot:1.2.3.RELEASE      | 
                         | 
                         | 
                   and the 1.2.3 here---- 

Und sicher genug, ich auf dem Laufzeit-Klassenpfad sah und es enthielt sowohl Version 1.2.3 und 1.3.3 des Frühlings-Boots. So scheint es, dass, da das XD DiRT Spring boot v1.2.3 verwendet, ich v1.3.3 nicht verwenden kann/sollte.

Meine Lösung scheint zu sein, verwenden Sie Spring Boot nicht.

Verwandte Themen