Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

Specifying dependencies

Stay organized with collections Save and categorize content based on your preferences.

You can use any Java compatible libraries with the Java 11/17 runtime on the App Engine standard environment. These instructions use Apache Maven to build, run, and deploy the sample app. For details about installing Maven, see Using Apache Maven and the App Engine Plugin.

Declaring and managing dependencies

To manage dependencies using Maven, you need to specify the dependencies in the <dependencies> section inside the pom.xml file of your project.

Private dependencies with Artifact Registry

If you need to host private dependencies for your Java app, you can use an Artifact Registry Maven repository. Connecting to a Maven repository hosted on Artifact Registry requires the Artifact Registry Maven Tools plugin for your Maven or Gradle configuration.

Specifying the Java servlet library

Eclipse Jetty and Tomcat apps require the Java servlet library. Specify it in your pom.xml file's <dependencies> entry:

<dependencies>

  <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <type>jar</type>
    <scope>provided</scope>
  </dependency>

</dependencies>

Note that frameworks such as SparkJava or Spring Boot will not require the servlet library.

Using the Cloud Client Libraries

Cloud Client Libraries for Java provide idiomatic access to Google Cloud services. To use a library, declare it as a dependency.

Typically, you only declare dependencies on the specific libraries that your app needs. For example, to use the Cloud Storage library:

<!--  Using libraries-bom to manage versions.
See https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM -->
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>libraries-bom</artifactId>
      <version>26.1.4</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

<dependencies>
  <dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-storage</artifactId>
  </dependency>
</dependencies>

You can configure the Cloud Client Libraries for Java to handle authentication automatically.