Building and managing Java function dependencies
Cloud Functions supports two methods of managing 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.
Dependency installation is limited in terms of resources and execution time. For more information, see Quotas and limits in Cloud Functions. You can view the dependency installation log via the link displayed in the list of operations.
Maven
Maven
To deliver dependencies, configure them in the pom.xml file. No other steps, including project compilation, are required.
To set the dependency loading order, 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 pom.xml.
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 may not work correctly with other versions of the libraries.