我正在尝试将aws-xray-recorder-sdk-spring
lib 添加到现有的 spring boot 服务中,如此处的文档中所述。
我在启动时收到此错误:
{"@timestamp":"2018-05-08T08:04:23.026+10:00","@version":1,"message":"Application run failed","logger_name":"org.springframework.boot.SpringApplication","thread_name":"main","level":"ERROR","level_value":40000,"stack_trace":"org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'meterRegistryPostProcessor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: org.springframework.data.repository.Repository [Xlint:invalidAbsoluteTypeName]
\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:591)
\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
\tat org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)
\tat org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:238)
\tat org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:709)
\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:534)
\tat org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)
\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
\tat net.nxbos.vti.Application.main(Application.java:34)
Caused by: java.lang.IllegalArgumentException: warning no match for this type name: org.springframework.data.repository.Repository [Xlint:invalidAbsoluteTypeName]
\tat org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:319)
\tat org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:226)
\tat org.springframework.aop.aspectj.AspectJExpressionPointcut.obtainPointcutExpression(AspectJExpressionPointcut.java:197)
\tat org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:176)
\tat org.springframework.aop.support.AopUtils.canApply(AopUtils.java:224)
\tat org.springframework.aop.support.AopUtils.canApply(AopUtils.java:283)
\tat org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:315)
\tat org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:124)
\tat org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:93)
\tat org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:74)
\tat org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:352)
\tat org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:304)
\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:438)
\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1714)
\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)
\t... 15 common frames omitted
"}
我已将拦截器设置为在带有注释的类上@XRayEnabled
运行
@Override
@Around("@annotation(com.amazonaws.xray.spring.aop.XRayEnabled)")
public void xrayEnabledClasses() {}
我spring-data
在我的项目中并没有对为什么 AOP 试图匹配它感到有点困惑。
这里有一篇文章提到启动时线程本地使用可能是罪魁祸首,并建议手动检测。如果可能,更愿意使用 AWS SDK,对上述错误有什么想法吗?
AWS X-Ray Recorder SDK 依赖于 InheritableThreadLocal 存储,以便在整个程序执行过程中传播有关当前(子)段的信息。似乎 Spring 正在使用预实例化的 ThreadPoolExecutor 来运行其 Bean 创建任务。因此,“InitializerListener”段在备用线程上创建后,对 I18nCache 初始化函数不可用。