当代码在amazon aws lambda中执行时,我的@autowired spring依赖项为null。有意义的,如果没有上下文被加载,但我认为SpringBeanAutowiringSupport将有所帮助。如何在amazon lambda中正确注入依赖关系?亚马逊aws lamba函数与弹簧autowired依赖关系
这是我的代码已经空自动装配领域,但另有正常工作(如果我顶替自动装配新:提前
@Component
public class ApplicationEventHandler {
@Autowired
private Foo foo;
public ApplicationEventHandler() {
logger.info("I'm sure the constructor is being called");
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
//doesn't seem to help
}
public void deliveryFailedPermanentlyHandler(SNSEvent event, Context context) throws IOException {
foo.doStuff() // causes NPE
}
感谢
这里是不涉及‘神奇’一个简单的方法:用Spring-只是AWS Lambda表达式(https://开头w^ww.profit4cloud.nl/blog/just-spring-enabled-aws-lambdas/) –