gpt4 book ai didi

java - 如何在 Java Azure 函数中使用事件中心触发器

转载 作者:行者123 更新时间:2023-12-03 05:27:49 25 4
gpt4 key购买 nike

我正在尝试创建一个从 Azure 事件中心触发的 Java Azure 函数。我正在关注这些代码片段:https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-hubs-trigger?tabs=java#example

这是我的代码:

package com.function;

import com.microsoft.azure.functions.*;
import com.microsoft.azure.function.annotation.*;

import java.util.Optional;

public class function {

@FunctionName("MTI")
public void EventHubProcess(
@EventHubTrigger(name = "msg", eventHubName = "mticallhub", connection = "EHubConnectionString"), String message, final ExecutionContext context)
{
context.getLogger().info("Java HTTP trigger processed a request: " + message);
}
}

这是我在构建时遇到的错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project func-MTI-test-zyg-001: Compilation failure
[ERROR] /C:/JavaStuff/FunctionApps/func-MTI-test-zyg-001/src/main/java/com/function/Function.java:[34,105] illegal start of type

这是 VSCode 中的错误弹出窗口: popup error in VSCode

我已经找了几个小时,并用尽了一页又一页的 Google 搜索。我做错了什么?

最佳答案

请更改

@EventHubTrigger(name = "msg", eventHubName = "mticallhub", connection = "EHubConnectionString"), String message, final ExecutionContext context)

@EventHubTrigger(name = "msg", eventHubName = "mticallhub", connection = "EHubConnectionString") String message, final ExecutionContext context)

enter image description here

关于java - 如何在 Java Azure 函数中使用事件中心触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67480309/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com