Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Anda dapat menggunakan salah satu library yang mendukung Java dalam runtime Java di lingkungan fleksibel App Engine.
Petunjuk ini menggunakan Apache Maven untuk mem-build, menjalankan, dan men-deploy aplikasi contoh menggunakan runtime Java yang didukung. Untuk mengetahui informasi selengkapnya tentang penggunaan versi Java yang didukung, lihat
runtime Java.
Untuk mengelola dependensi menggunakan Maven, Anda perlu menentukan dependensi di
bagian <dependencies> di dalam
file pom.xml
project Anda.
Untuk mengelola dependensi project di Maven itu sendiri, Anda dapat menggunakan
Maven Wrapper. Jika Anda tidak menggunakan
Maven Wrapper, App Engine secara default akan menggunakan Maven versi terbaru
saat menjalankan gcloud app deploy.
Menentukan library servlet Java
Aplikasi Eclipse Jetty dan Tomcat memerlukan library Java servlet. Tentukan dalam
entri <dependencies> file pom.xml Anda:
Perhatikan bahwa framework seperti SparkJava
atau Spring Boot
tidak memerlukan library servlet.
Menggunakan Library Klien Cloud
Library Klien Cloud untuk Java
menyediakan akses idiomatis ke layanan Google Cloud. Untuk menggunakan library, deklarasikan
sebagai dependensi.
Biasanya, Anda hanya mendeklarasikan dependensi pada library tertentu yang diperlukan aplikasi
Anda. Misalnya, untuk menggunakan library Cloud Storage:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)."]]