我对 Azure 功能完全陌生。 我发现这是一个有趣的话题。现在,我已经开发了 azure 函数并且工作正常。 但我的故事不会在这里结束。在函数方法中,我尝试在 Spring Autowiring 我的存储库类,以便访问我的数据库层。 但它给了我一个空指针异常。意味着“@Autowired”注释不起作用并且不会启动我的 HotelController 类。 任何想法,为什么我无法在 Azure 函数中获取实例?
最佳答案
我认为你应该看看:
spring-cloud-function-adapter-azure
This project provides an adapter layer for a Spring Cloud Function application onto Azure. You can write an app with a single
@Bean
of typeFunction
and it will be deployable in Azure if you get the JAR file laid out right.There is an
AzureSpringBootRequestHandler
which you must extend, and provide the input and output types as annotated method parameters (enabling Azure to inspect the class and create JSON bindings). The base class has two useful methods (handleRequest
andhandleOutput
) to which you can delegate the actual function call, so mostly the function will only ever have one line.还有sample这展示了如何使用它。
希望对您有帮助!
关于spring - Autowired 无法与 Azure 功能一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53939608/