Building and managing Java function dependencies
Cloud Functions supports two ways to manage Java function dependencies: 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.
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.
Maven
Maven
To deliver dependencies, configure them in the pom.xml
file. No other actions, including project compilation, are required.
To set the loading order for dependencies, upload a file named classpath.txt
to the project root. This file must list the dependencies line by line 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 required libraries in the project archive root. Example:
build.zip
+--org
+----package
+------Main.java
+--dependency.jar
Recommended versions of Java libraries
Java 11 |
Java 17, Java 21 |
|
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.