当我部署我的 jar
在gcp云函数文件中,我得到以下异常
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)
这是我在cli中遇到的另一个错误
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
这是我的源代码
这是我 Spring 的主要课程
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云函数中部署时,它并没有开始和停止,只是我在上面粘贴了一个例外
暂无答案!
目前还没有任何答案,快来回答吧!