我正在尝试使用 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 Bean
firstFunction
secondFunction
在进行了一些谷歌搜索后,我发现了这个建议移至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).
需要一些关于我做错了什么的帮助。