spring - Autowired 无法与 Azure 功能一起使用

标签 spring azure spring-boot azure-functions

enter image description here

我对 Azure 功能完全陌生。 我发现这是一个有趣的话题。现在,我已经开发了 azure 函数并且工作正常。 但我的故事不会在这里结束。在函数方法中,我尝试在 Spring Autowiring 我的存储库类,以便访问我的数据库层。 但它给了我一个空指针异常。意味着“@Autowired”注释不起作用并且不会启动我的 HotelController 类。 任何想法,为什么我无法在 Azure 函数中获取实例?

最佳答案

我认为你应该看看:

  1. 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 type Function 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 and handleOutput) to which you can delegate the actual function call, so mostly the function will only ever have one line.

  2. 还有sample这展示了如何使用它。

希望对您有帮助!

关于spring - Autowired 无法与 Azure 功能一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53939608/

相关文章:

java - Spring Snake 大小写转换不适用于外键列

java - 为什么spring不使用ajax上传呢?

java - 如何使用 Gitlab CI 构建 Java Maven 项目?

node.js - 如何检测 Azure 网站上的 HTTPS 重定向?

java - 将值从 thymeleaf 发送到 Spring Boot 服务类

mysql - 奇怪的 mysqlSyntaxErrorException 与 mybatis-spring

azure - 将 AzAccount 与 Azure Devops Pipeline 连接?

spring-boot - Camel 从 activemq 路由到 rest 端点

java - 如何在 Spring Boot WebFlux 中使用 GET 请求注销