【发布时间】:2018-10-31 03:49:00
【问题描述】:
我正在构建一个基于 lambda 的 on this code
uppercaseService 是这样“注入”的:
@Component("uppercaseFunction")
public class UppercaseFunction implements Function<UppercaseRequest, UppercaseResponse> {
private final UppercaseService uppercaseService;
public UppercaseFunction(final UppercaseService uppercaseService) {
this.uppercaseService = uppercaseService;
}
这工作正常,直到我尝试在 UppercaseService 中注入另一个服务。
@Service
public class UppercaseService {
@Autowired
MyService myService;
public String uppercase(final String input) {
myService.doSomething();
return input.toUpperCase(Locale.ENGLISH);
}
}
AWS 控制台返回:
"errorMessage": "创建名为 'uppercaseService' 的 bean 时出错: 通过字段 'myService' 表达的不满足的依赖关系
此服务在非 lambda 上下文中工作。该类存在于使用 maven 包构建的 .jar 中。
我尝试了@https://www.profit4cloud.nl/blog/just-spring-enabled-aws-lambdas的解决方案,但没有成功。
【问题讨论】:
-
你在哪里创建
MyService类型的bean? -
@MạnhQuyếtNguyễn 它来自外部 springboot 项目。
标签: java spring amazon-web-services spring-boot aws-lambda