尝试运行azure-sample,但在收到请求时遇到“无法找到主类”错误。
使用Maven在Eclipse中构建项目。根据{{3}}更新了代码(否则您将获得ClassCast异常)。
在本地或远程(部署后)运行会产生相同的错误。
除了指向我的functionAppName,Region,ResourceGroup以准备部署之外,没有更改示例中的POM。
Executed 'Functions.uppercase' (Failed, Id=349ca69e-4548-4af2-b6a4-84bf5afbedb5)
[4/10/19 9:03:39 PM] System.Private.CoreLib: Exception while executing function: Functions.uppercase. System.Private.CoreLib: Result: Failure
[4/10/19 9:03:39 PM] Exception: IllegalArgumentException: Failed to locate main class
[4/10/19 9:03:39 PM] 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).
[4/10/19 9:03:39 PM] at org.springframework.cloud.function.context.AbstractSpringFunctionAdapterInitializer.getStartClass(AbstractSpringFunctionAdapterInitializer.java:279)
[4/10/19 9:03:39 PM] at org.springframework.cloud.function.context.AbstractSpringFunctionAdapterInitializer.<init>(AbstractSpringFunctionAdapterInitializer.java:99)
[4/10/19 9:03:39 PM] at org.springframework.cloud.function.adapter.azure.AzureSpringBootRequestHandler.<init>(AzureSpringBootRequestHandler.java:44)
[4/10/19 9:03:39 PM] at example.FooHandler.<init>(FooHandler.java:33)
[4/10/19 9:03:39 PM] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[4/10/19 9:03:39 PM] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[4/10/19 9:03:39 PM] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[4/10/19 9:03:39 PM] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[4/10/19 9:03:39 PM] at java.lang.Class.newInstance(Class.java:442)
[4/10/19 9:03:39 PM] at com.microsoft.azure.functions.worker.broker.JavaMethodExecutor.lambda$execute$1(JavaMethodExecutor.java:54)
[4/10/19 9:03:39 PM] at com.microsoft.azure.functions.worker.broker.JavaMethodInvokeInfo.invoke(JavaMethodInvokeInfo.java:20)
[4/10/19 9:03:39 PM] at com.microsoft.azure.functions.worker.broker.JavaMethodExecutor.execute(JavaMethodExecutor.java:54)
[4/10/19 9:03:39 PM] at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:51)
[4/10/19 9:03:39 PM] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:33)
[4/10/19 9:03:39 PM] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
[4/10/19 9:03:39 PM] at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45)
[4/10/19 9:03:39 PM] at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92)
[4/10/19 9:03:39 PM] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[4/10/19 9:03:39 PM] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[4/10/19 9:03:39 PM] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[4/10/19 9:03:39 PM] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[4/10/19 9:03:39 PM] at java.lang.Thread.run(Thread.java:748)
[4/10/19 9:03:39 PM] Caused by: java.lang.IllegalArgumentException: Failed to locate main class
[4/10/19 9:03:39 PM] at org.springframework.util.Assert.notNull(Assert.java:198)
[4/10/19 9:03:39 PM] at org.springframework.cloud.function.context.AbstractSpringFunctionAdapterInitializer.getStartClass(AbstractSpringFunctionAdapterInitializer.java:275)
[4/10/19 9:03:39 PM] ... 21 more
编辑:azure-functions文件夹中的jar似乎与Thin Spring maven插件创建的最终jar不同。清单文件包含不同的电源。 azure-functions jar似乎只是maven-jar-plugin的结果,但是它仍然引用@SpringBootApplication类作为其主要对象。那还行吗?在此示例中,完全使用薄包装纸有什么意义?
答案 0 :(得分:0)
目前,可以通过将spring-cloud-function-dependencies版本更改为2.0.1.RELEASE来解决
还要注意,构建后,所有application.properties都应放在azure-functions文件夹中。这可以通过几种方法完成。