【发布时间】:2019-10-25 04:23:26
【问题描述】:
我正在尝试使用 Spring Cloud 创建 2 个 Azure Functions,但无法使其工作。
@Configuration
public class FirstFunction extends AzureSpringBootRequestHandler<Optional<Void>, String>
{
@FunctionName("firstFunction")
public void run(
@HttpTrigger(name = "req", methods = {HttpMethod.POST}, authLevel = AuthorizationLevel.FUNCTION) HttpRequestMessage<Optional<String>> request,
final ExecutionContext context)
{
handleRequest(Optional.empty(), context);
}
@Bean
@Lazy
Function<Optional<Void>, String> firstFunction()
{
return context ->
{
// do firstFunction stuff;
};
}
}
@Configuration
public class SecondFunction extends AzureSpringBootRequestHandler<Optional<Void>, String>
{
@FunctionName("secondFunction")
public void run(
@HttpTrigger(name = "req", methods = {HttpMethod.POST}, authLevel = AuthorizationLevel.FUNCTION) HttpRequestMessage<Optional<String>> request,
final ExecutionContext context)
{
handleRequest(Optional.empty(), context);
}
@Bean
@Lazy
Function<Optional<Void>, String> secondFunction()
{
return context ->
{
// do secondFunction stuff;
};
}
}
@SpringBootApplication
public class Application
{
public static void main(final String[] args)
{
SpringApplication.run(Application.class, args);
}
}
使用依赖于spring-cloud-function-dependencies 2.0.1.RELEASE 的上述代码,当同时调用firstFunction 和secondFunction 端点时,它总是命中firstFunction Bean。
在谷歌上搜索后,我发现这个SO answer 建议转移到2.1。
但是,当我尝试更改为 2.1.1.RELEASE 时,我遇到了无法找到主类的异常:
System.Private.CoreLib: Exception while executing function: Functions.extractContent. System.Private.CoreLib: Result: Failure
Exception: IllegalArgumentException: Failed to locate main class
Stack: java.lang.IllegalStateException: Failed to discover main class. An attempt was made to discover main class as 'MAIN_CLASS' environment variable, system property as well as entry
in META-INF/MANIFEST.MF (in that order).
我做错了什么需要一些帮助。
【问题讨论】:
标签: java spring azure-functions spring-cloud spring-cloud-function