Building and managing Java function dependencies
Cloud Functions supports two ways to manage dependencies for a Java function: automatic installation from the source code using Maven
and adding dependencies manually to a project archive. However, you cannot configure dependencies using both methods at the same time.
Maven
MavenJava
.
To deliver dependencies using Maven
, just upload your own Maven
project by configuring dependencies in pom.xml
. No other actions, including project compilation, are required.
If you want to set the order of loading dependencies, upload a file named classpath.txt
to the project root. This file lists the dependencies one by one in the required order.
Warning
Make sure the project archive root contains the pom.xml
file.
Manual delivery of dependencies
To configure dependencies manually, place the jar
archives of the necessary libraries in the root of the project archive. Example:
build.zip
+--org
+----package
+------Main.java
+--dependency.jar
The process of installing dependencies has resource and execution time limits. For more information, see Quotas and limits in Cloud Functions. You can view the dependency installation log using the link that appears in the list of operations.
Recommended versions of Java libraries
Java 11 |
Java 17 |
|
Spring Boot |
2.3.4.RELEASE |
2.5.14 |
Spring Framework |
5.2.9.RELEASE |
5.3.24 |
javax.servlet |
4.0.1 |
4.0.1 |
Warning
Functions are not guaranteed to work correctly with other versions of the libraries.