Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
L'environnement d'exécution Java sur l'environnement flexible App Engine permet d'utiliser toutes les bibliothèques compatibles avec Java.
Ces instructions s'appuient sur Apache Maven pour créer, exécuter et déployer un exemple d'application utilisant un environnement d'exécution Java compatible. Pour en savoir plus sur l'utilisation des versions Java compatibles, consultez la page Environnement d'exécution Java.
Vous devez spécifier les dépendances dans la section <dependencies> du fichier pom.xml de votre projet afin de les gérer à l'aide de Maven.
Pour gérer la dépendance de votre projet sur Maven, vous pouvez utiliser le wrapper Maven. Si vous n'utilisez pas le wrapper Maven, App Engine utilise par défaut une version récente de Maven lors de l'exécution de gcloud app deploy.
Spécifier la bibliothèque de servlets Java
Les applications Eclipse, Jetty et Tomcat nécessitent la bibliothèque de servlets Java. Précisez-le dans l'entrée <dependencies> du fichier pom.xml :
Notez que des frameworks tels que SparkJava et Spring Boot ne nécessitent pas la bibliothèque de servlets.
Utiliser les bibliothèques clientes Cloud
Les bibliothèques clientes Cloud pour Java fournissent un accès idiomatique aux services Google Cloud. Pour utiliser une bibliothèque, déclarez-la en tant que dépendance.
En règle générale, vous ne pouvez déclarer des dépendances que pour les bibliothèques dont votre application a besoin. Par exemple, pour utiliser la bibliothèque Cloud Storage :
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)."]]