【问题标题】:Quarkus: CDI not working when using Google Cloud FunctionsQuarkus:使用 Google Cloud Functions 时 CDI 不工作
【发布时间】:2020-11-20 09:19:05
【问题描述】:

我遵循了QUARKUS - GOOGLE CLOUD FUNCTIONS 教程,但依赖注入似乎在该上下文中不起作用,因为任何@Inject'ed 对象在运行时都是null

下载并运行the tutorial solution 给我同样的结果。

我错过了什么吗?

【问题讨论】:

    标签: google-cloud-functions cdi quarkus


    【解决方案1】:

    此错误通常是由于在gcloud 命令中使用了错误的入口点。

    必须使用 Quarkus 提供的函数,而不是您的函数作为 gcloud 命令的入口点类。

    这在指南https://quarkus.io/guides/gcp-functions#build-and-deploy-to-google-cloud的这一部分中有描述,也许我们需要更清楚。

    对于后台功能,使用gcloud functions deploy my-function --entry-point --entry-point=io.quarkus.gcp.functions.QuarkusBackgroundFunction ...

    对于 HTTP 函数,使用 gcloud functions deploy my-function --entry-point --entry-point=io.quarkus.gcp.functions.QuarkusHttpFunction ...

    Quarkus 函数将引导框架(包括 CDI),搜索您的函数并在其中注入依赖项。

    【讨论】:

      猜你喜欢
      • 2020-04-08
      • 2019-07-26
      • 1970-01-01
      • 2020-03-31
      • 2021-12-26
      • 1970-01-01
      • 2020-03-15
      • 2021-05-11
      • 2017-06-27
      相关资源
      最近更新 更多