I came across the Spring Cloud Function site (https://docs.spring.io/spring-cloud-function/docs/3.1.3/reference/html/spring-cloud-function.html#_getting_started) and thought it looked neat. I wanted to follow the getting started guide, since it looked like a tutorial designed for Spring beginners, and try out deploying a function to GCP, which is the public cloud platform I'm most familiar with.
I followed the instructions on that page. Something immediately seemed off, as if the instructions in the Getting Started guide were out of date, because the first command I'm instructed to run is mvnw clean install despite there being no mvnw file in the root of the cloned repo. I did understand though that I should just run mvn clean install instead, the idea being it would use my system Maven instead of a wrapper from the repo.
After that, it says to run java -jar spring-cloud-function-samples/function-sample/target/*.jar, but when I run that, I get the error: Error: Unable to access jarfile spring-cloud-function-samples/function-sample/target/*.jar. It looks like that command is something I'd run to run a JAR that should exist at that point. But there's no JAR file there and there's no target directory either.
I decided to cd into one of the specific example directories and try other commands to just run the code as is, without trying to build an artifact like a JAR. I chose "function-sample" because it looked to be the most basic one. I tried running mvn install from that directory and got an error:
Could not resolve dependencies for project io.spring.sample:function-sample:jar:2.0.0.RELEASE: org.springframework.cloud:spring-cloud-function-compiler:jar:3.2.0-SNAPSHOT was not found in https://repo.spring.io/libs-snapshot-local during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spring-snapshots has elapsed or updates are forced
I notice that it also has a build.gradle file though, and a gradlew wrapper, so I try ./gradlew and I get the output:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/matt/code/github.com/spring-cloud/spring-cloud-function/spring-cloud-function-samples/function-sample/build.gradle' line: 21
* What went wrong:
A problem occurred evaluating root project 'function-sample'.
> Plugin with id 'spring-boot' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.548 secs
It looks like it's supposed to use a Spring Boot plugin, but it fails to do so. I remembered reading in Gradle tutorials that you often start an application locally using ./gradlew runBoot so I tried that, but got the same error.
Java version:
> java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)
I'm using 8 intentionally instead of a more recent version because in build.gradle of the sample I wanted to run, it says:
sourceCompatibility = 1.8
targetCompatibility = 1.8
So it appears that the code can only use Java 8. I uninstalled Java 11 that I had installed via APT, installed sdkman, and used sdkman to install the latest HotSpot OpenJDK for Java 8.
I came across the Spring Cloud Function site (https://docs.spring.io/spring-cloud-function/docs/3.1.3/reference/html/spring-cloud-function.html#_getting_started) and thought it looked neat. I wanted to follow the getting started guide, since it looked like a tutorial designed for Spring beginners, and try out deploying a function to GCP, which is the public cloud platform I'm most familiar with.
I followed the instructions on that page. Something immediately seemed off, as if the instructions in the Getting Started guide were out of date, because the first command I'm instructed to run is
mvnw clean installdespite there being nomvnwfile in the root of the cloned repo. I did understand though that I should just runmvn clean installinstead, the idea being it would use my system Maven instead of a wrapper from the repo.After that, it says to run
java -jar spring-cloud-function-samples/function-sample/target/*.jar, but when I run that, I get the error:Error: Unable to access jarfile spring-cloud-function-samples/function-sample/target/*.jar. It looks like that command is something I'd run to run a JAR that should exist at that point. But there's no JAR file there and there's notargetdirectory either.I decided to cd into one of the specific example directories and try other commands to just run the code as is, without trying to build an artifact like a JAR. I chose "function-sample" because it looked to be the most basic one. I tried running
mvn installfrom that directory and got an error:I notice that it also has a
build.gradlefile though, and agradlewwrapper, so I try./gradlewand I get the output:It looks like it's supposed to use a Spring Boot plugin, but it fails to do so. I remembered reading in Gradle tutorials that you often start an application locally using
./gradlew runBootso I tried that, but got the same error.Java version:
I'm using 8 intentionally instead of a more recent version because in
build.gradleof the sample I wanted to run, it says:So it appears that the code can only use Java 8. I uninstalled Java 11 that I had installed via APT, installed sdkman, and used sdkman to install the latest HotSpot OpenJDK for Java 8.