问题描述
当我在 GCP 云函数中部署我的 jar
文件时,出现以下异常
2021-03-11T17:30:04.835Zarun-function-http Exception in thread "main" java.lang.RuntimeException: Class com.arun.serverless.CloudFunctionMain does not implement com.google.cloud.functions.HttpFunction at com.google.cloud.functions.invoker.HttpFunctionExecutor.forClass(HttpFunctionExecutor.java:47) at com.google.cloud.functions.invoker.runner.Invoker.startServer(Invoker.java:252) at com.google.cloud.functions.invoker.runner.Invoker.main(Invoker.java:127)
Exception in thread "main" java.lang.RuntimeException: Class com.arun.serverless.CloudFunctionMain does not implement com.google.cloud.functions.HttpFunction at com.google.cloud.functions.invoker.HttpFunctionExecutor.forClass(HttpFunctionExecutor.java:47) at com.google.cloud.functions.invoker.runner.Invoker.startServer(Invoker.java:252) at com.google.cloud.functions.invoker.runner.Invoker.main(Invoker.java:127)
ERROR: (gcloud.alpha.functions.deploy) OperationError: code=3,message=Build Failed: build succeeded but did not produce the class "org.springframework.cloud.function.adapter.gcp.GcfJarLauncher" specified as the function target: Error: class not found: org.springframework.cloud.function.adapter.gcp.GcfJarLauncher; Error ID: d818fd83
这是我的春季主课
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class CloudFunctionMain {
public static void main(String[] args) {
SpringApplication.run(CloudFunctionMain.class,args);
}
}
这是我的职责
import java.util.function.Function;
public class ReverseString implements Function<String,String> {
@Override
public String apply(String actualString) {
return "The reversed string is " + new StringBuilder(actualString).reverse().toString();
}
}
这是我的 build.gradle
包含的内容
plugins {
id 'java'
}
group 'com.arun'
//version '1.0'
repositories {
mavenRepository()
}
dependencies {
implementation 'org.springframework.cloud:spring-cloud-function-adapter-gcp:3.1.1'
implementation 'org.springframework.cloud:spring-cloud-starter-function-web:3.1.1'
}
它在我的本地工作得很好......但是当我在 GCP Cloud 函数中部署时,它没有开始和停止,除了我粘贴在上面
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)