Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Puoi utilizzare qualsiasi libreria compatibile con Java con il runtime Java nell'ambiente flessibile di App Engine.
Queste istruzioni utilizzano Apache Maven per creare, eseguire e implementare un'app di esempio utilizzando un runtime Java supportato. Per ulteriori informazioni sull'utilizzo delle versioni Java supportate, consulta la sezione
Runtime Java.
Per gestire le dipendenze utilizzando Maven, devi specificarle nella sezione <dependencies> all'interno del file pom.xml del tuo progetto.
Per gestire la dipendenza del progetto da Maven, puoi utilizzare
Maven Wrapper. Se non utilizzi
Maven Wrapper, App Engine utilizza per impostazione predefinita una versione recente di Maven
quando esegue gcloud app deploy.
Specifica la libreria servlet Java
Le app Eclipse Jetty e Tomcat richiedono la libreria servlet Java. Specificalo nella voce <dependencies> del file pom.xml:
Tieni presente che framework come SparkJava
o Spring Boot
non richiedono la libreria servlet.
Utilizzare le librerie client di Cloud
Le librerie client di Cloud per Java forniscono un accesso idiomatico ai servizi Google Cloud. Per utilizzare una libreria, dichiarala
come dipendenza.
In genere, dichiari solo le dipendenze dalle librerie specifiche di cui la tua app
ha bisogno. Ad esempio, per utilizzare la libreria Cloud Storage:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThe App Engine flexible environment allows the use of any Java-compatible libraries with the Java runtime.\u003c/p\u003e\n"],["\u003cp\u003eApache Maven is used to build, run, and deploy apps using a supported Java runtime, and it is also used to manage dependencies in the \u003ccode\u003epom.xml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eJava servlet library is required for Eclipse Jetty and Tomcat apps and must be specified in the \u003ccode\u003epom.xml\u003c/code\u003e file, but frameworks like SparkJava or Spring Boot do not need this.\u003c/p\u003e\n"],["\u003cp\u003eCloud Client Libraries for Java provide access to Google Cloud services, and their dependencies are declared in the \u003ccode\u003epom.xml\u003c/code\u003e file, typically only for the libraries your app uses.\u003c/p\u003e\n"]]],[],null,["# Specifying dependencies\n\nYou can use any Java compatible libraries with the Java runtime on the\nApp Engine flexible environment.\n\nThese instructions use Apache Maven to build, run, and deploy a sample app using\na [supported](/appengine/docs/flexible/lifecycle/support-schedule#java) Java\nruntime. For more information about using supported Java versions, see the\n[Java runtime](/appengine/docs/flexible/java/runtime).\nFor details about installing Maven, see [Using Apache Maven and the App Engine plugin](/appengine/docs/flexible/java/using-maven).\n\n\u003cbr /\u003e\n\nDeclare and manage dependencies\n-------------------------------\n\nTo manage dependencies using Maven, you need to specify the dependencies in\nthe `\u003cdependencies\u003e` section inside the\n[`pom.xml`](http://maven.apache.org/guides/introduction/introduction-to-the-pom.html)\nfile of your project.\n\nTo manage your project's dependency on Maven itself, you can use the\n[Maven Wrapper](https://maven.apache.org/wrapper/). If you do not use the\nMaven Wrapper, App Engine defaults to using a recent version of Maven\nwhen running [`gcloud app deploy`](/sdk/gcloud/reference/app/deploy).\n\nSpecify the Java servlet library\n--------------------------------\n\nEclipse Jetty and Tomcat apps require the Java servlet library. Specify it in\nyour `pom.xml` file's `\u003cdependencies\u003e` entry:\n\n\n \u003cdependency\u003e\n \u003cgroupId\u003ecom.example.appengine\u003c/groupId\u003e\n \u003cartifactId\u003esimple-jetty-main\u003c/artifactId\u003e\n \u003cversion\u003e1\u003c/version\u003e\n \u003cscope\u003eprovided\u003c/scope\u003e\n \u003c/dependency\u003e\n\nNote that frameworks such as [SparkJava](http://sparkjava.com/) or [Spring Boot](http://projects.spring.io/spring-boot/) won't require the servlet library.\n\n\u003cbr /\u003e\n\nUse the Cloud Client Libraries\n------------------------------\n\n[Cloud Client Libraries for Java](https://github.com/googleapis/google-cloud-java)\nprovide idiomatic access to Google Cloud services. To use a library, declare\nit as a dependency.\n\nTypically, you only declare dependencies on the specific libraries that your app\nneeds. For example, to use the Cloud Storage library:\n\n\n \u003c!-- Using libraries-bom to manage versions.\n See https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM --\u003e\n \u003cdependencyManagement\u003e\n \u003cdependencies\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003ecom.google.cloud\u003c/groupId\u003e\n \u003cartifactId\u003elibraries-bom\u003c/artifactId\u003e\n \u003cversion\u003e26.28.0\u003c/version\u003e\n \u003ctype\u003epom\u003c/type\u003e\n \u003cscope\u003eimport\u003c/scope\u003e\n \u003c/dependency\u003e\n \u003c/dependencies\u003e\n \u003c/dependencyManagement\u003e\n\n \u003cdependencies\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003ecom.google.cloud\u003c/groupId\u003e\n \u003cartifactId\u003egoogle-cloud-storage\u003c/artifactId\u003e\n \u003c/dependency\u003e\n \u003c/dependencies\u003e\n\nYou can configure the Cloud Client Libraries for Java to\n[handle authentication automatically](/docs/authentication/client-libraries)."]]