小编Ven*_*nus的帖子

Spring 和 Azure 函数

Spring 可以与 Azure 函数一起使用吗?

例如:内部代码使用“Autowired”注释的 Rest API(运行 mvn azure-functions:run 后,我在“myScriptService”上遇到 NullPointerException)。

import java.util.*;
import com.microsoft.azure.serverless.functions.annotation.*;
import com.microsoft.azure.serverless.functions.*;
import com.company.ScriptService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Azure Functions with HTTP Trigger.
 */
public class Function {

    @Autowired
    ScriptService myScriptService;
    /**
     * This function listens at endpoint "/api/hello". Two ways to invoke it using "curl" command in bash:
     * 1. curl -d "HTTP Body" {your host}/api/hello
     * 2. curl {your host}/api/hello?name=HTTP%20Query
     */
    @FunctionName("myhello")
    public HttpResponseMessage<String> hello(
            @HttpTrigger(name = "req", 
                        methods = "post", 
                        authLevel = …
Run Code Online (Sandbox Code Playgroud)

spring azure-functions

5
推荐指数
1
解决办法
2881
查看次数

标签 统计

azure-functions ×1

spring ×1