JavaSpringAzure函数抛出初始化的上下文:catalog=null,illegalstateexception:没有用名称定义函数

ecr0jaav  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(237)

我有一个JavaAzure函数与SpringBoot集成。由于某些原因,应用程序在尝试查找已定义的spring函数时会抛出错误:
这就是函数 EventHubTriggerFunction.java :

public class EventHubTriggerFunction extends AzureSpringBootRequestHandler<String, String> {

    @FunctionName("messageRouter")
    public void run(
            @BindingName("SystemProperties") Map<String, Object> systemProperties,
            @BindingName("Properties") Map<String, Object> properties,
            @EventHubTrigger(name = "message", eventHubName = "eventhubName", connection = "conn", consumerGroup = "$Default", cardinality = Cardinality.ONE) String message,
            final ExecutionContext context
    ) {
        String s = handleRequest(message, context);
        context.getLogger().info(s);

    }
}

这是我的春靴 Application.java :

@SpringBootApplication
public class Application {

  @Bean
  public Function<String, String> messageRouter() {
    return value -> "HELLO FROM SPRING";
  }

  public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }
}

如果正在处理消息,则返回错误:

2020-11-25T09:53:01.320 [Information] Initialized context: catalog=null
2020-11-25T09:53:01.355 [Error] Executed 'Functions.messageRouter' (Failed, Id=8c680fe7-a275-4038-83d1-7ba7acb65129, Duration=129ms)Result: FailureException: IllegalStateException: No function defined with name=messageRouter

函数本身正在触发+处理,直到 handleRequest() 正在接到电话。此代码基于这里的示例(包括pom)。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题