我目前正在使用 Spring 4.1.4 使用 STS 3.6.3SR1。尝试测试 spring-cloud-aws 在我们的应用程序中使用的可行性。
与问题相关的罐子:
- spring-cloud-aws-autoconfigure-1.0.0.RC2.jar
- spring-cloud-aws-context-1.0.0.RC2.jar
- spring-cloud-aws-core-1.0.0.RC2.jar
- spring-cloud-aws-messaging-1.0.0.RC2.jar
使用 aws-sdk-1.9.19
这是我在 spring-cloud-aws starter page之后的 applicationContext 文件。
<aws-context:context-region region="us-east-1"/>
<aws-context:context-credentials>
<aws-context:simple-credentials
access-key="*******" secret-key="*******"/>
</aws-context:context-credentials>
<aws-messaging:queue-messaging-template id="queueMessagingTemplate" />
<aws-messaging:annotation-driven-queue-listener />
Spring-cloud-aws 的起始页建议 queuemessagingtemplate bean 在使用消息传递命名空间时会自动注入一个 AmazonSQS bean。但是,据我了解,我遇到了关于将字符串值区域转换为 AWS 枚举值区域的错误。
以下是相关日志:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'amazonSQSAsync': Cannot create inner bean '(inner bean)#23ea780a' of type [com.amazonaws.services.sqs.AmazonSQSAsyncClient] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#23ea780a': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.amazonaws.regions.Region' to required type 'com.amazonaws.regions.Regions' for property 'region'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.amazonaws.regions.Region] to required type [com.amazonaws.regions.Regions] for property 'region': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:129)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:634)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:140)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1131)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1034)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5524)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#23ea780a': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.amazonaws.regions.Region' to required type 'com.amazonaws.regions.Regions' for property 'region'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.amazonaws.regions.Region] to required type [com.amazonaws.regions.Regions] for property 'region': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299)
... 26 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.amazonaws.regions.Region' to required type 'com.amazonaws.regions.Regions' for property 'region'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.amazonaws.regions.Region] to required type [com.amazonaws.regions.Regions] for property 'region': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:475)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:511)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:505)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1515)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1474)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 28 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [com.amazonaws.regions.Region] to required type [com.amazonaws.regions.Regions] for property 'region': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:287)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:460)
... 34 more
有人可以阐明我的上下文文件是否不正确吗?我相信us-east-1是指定区域的正确方法,但我错过了什么吗?
谢谢你。