คู่มือเริ่มต้นฉบับย่อสำหรับ Java
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
โครงการนี้จะแสดงให้คุณเห็นวิธีการนำ
กลาสแวร์ตัวหนึ่งที่สาธิตฟังก์ชันการทำงานหลักๆ ของ Google Mirror API
ดูการสาธิตการใช้งานฉบับย่อของโปรเจ็กต์คู่มือเริ่มต้นได้ที่
https://glass-python-starter-demo.appspot.com.
หรืออ่านต่อไปเพื่อดูวิธีทำให้เวอร์ชันของคุณใช้งานได้
ดาวน์โหลดบน GitHub
ข้อกำหนดเบื้องต้น
โปรดตรวจสอบว่าระบบมีคุณสมบัติตรงตามข้อกำหนดเบื้องต้นต่อไปนี้สำหรับโปรเจ็กต์การเริ่มต้นอย่างรวดเร็ว
- Java 1.6
- Apache Maven - ใช้เพื่อเป็นส่วนหนึ่งของกระบวนการบิลด์
การสร้างโปรเจ็กต์คอนโซล Google APIs
ถัดไป ให้เปิดใช้งานการเข้าถึง Google Mirror API โดยทำดังนี้
- ไปที่คอนโซล Google API แล้วสร้างโปรเจ็กต์ API ใหม่
- คลิกบริการและเปิดใช้ Google Mirror API สำหรับโปรเจ็กต์ใหม่

- คลิกการเข้าถึง API และสร้างรหัสไคลเอ็นต์ OAuth 2.0 สำหรับเว็บแอปพลิเคชัน

- ระบุชื่อและไอคอนผลิตภัณฑ์สำหรับ Glassware ของคุณ ช่องเหล่านี้ปรากฏบนการให้สิทธิ์ OAuth
ที่แสดงให้ผู้ใช้เห็น

- เลือกเว็บแอปพลิเคชัน แล้วระบุค่าสำหรับชื่อโฮสต์ เช่น
localhost

- คลิกแก้ไขการตั้งค่า... สำหรับรหัสไคลเอ็นต์เพื่อระบุ URI การเปลี่ยนเส้นทาง ระบุ URL เรียกกลับ
สำหรับเว็บเซิร์ฟเวอร์การพัฒนาภายใน เช่น
http://localhost:8080/oauth2callback
และ
สำหรับเว็บเซิร์ฟเวอร์ที่ทำให้ใช้งานได้ เช่น https://example.com/oauth2callback

- จดบันทึกรหัสไคลเอ็นต์และข้อมูลลับจากคอนโซล Google APIs คุณจะต้องมี
เพื่อกำหนดค่าโปรเจ็กต์เริ่มต้นอย่างรวดเร็ว

กำหนดค่าโปรเจ็กต์การเริ่มต้นอย่างรวดเร็วเพื่อใช้ข้อมูลไคลเอ็นต์ API ของคุณโดยป้อนรหัสไคลเอ็นต์และ
ข้อมูลลับไปยัง src/main/resources/oauth.properties
:
# Replace these with values for your project from the Google API Console:
# https://developers.google.com/console
client_id=3141592653589793238462643383279
client_secret=ITS_A_SECRET_TO_EVERYBODY
กำลังนำเข้าโปรเจ็กต์
วิธีการต่อไปนี้แสดงวิธีนำเข้าแหล่งที่มาของโปรเจ็กต์ Quick Start ไปยัง IntelliJ และ
สุริยุปราคา
อินเทลลิเจ
- คลิกไฟล์ > นำเข้าโปรเจ็กต์...
- ชี้ไปที่ไดเรกทอรีที่ดึงข้อมูลมา
- เลือก นำเข้าจากโมเดลที่มีอยู่ > Maven
Eclipse
- ติดตั้งปลั๊กอิน
m2e
เพื่อเปิดใช้การนำเข้าจากไฟล์ maven Pom
- คลิกไฟล์ > นำเข้า... เมเวน > โปรเจ็กต์ Maven ที่มีอยู่
- ชี้ไปที่ไดเรกทอรีที่แตกข้อมูลแล้วนำเข้าโปรเจ็กต์
การเรียกใช้เซิร์ฟเวอร์การพัฒนาซอฟต์แวร์ภายใน
คุณสามารถเรียกใช้โปรเจ็กต์ Quick Start ในเซิร์ฟเวอร์การพัฒนาภายในเพื่อทดสอบ
$ mvn jetty:run
การทำให้โปรเจ็กต์ Quick Start ใช้งานได้
คุณสามารถสร้างไฟล์ war สำหรับโครงการนี้โดยใช้ Maven:
$ mvn war:war
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[[["\u003cp\u003eThis project provides a simple implementation of Glassware demonstrating core Google Mirror API functionality.\u003c/p\u003e\n"],["\u003cp\u003eIt requires Java 1.6, Apache Maven, and a Google APIs Console project with the Google Mirror API enabled and OAuth 2.0 client ID created.\u003c/p\u003e\n"],["\u003cp\u003eThe project can be configured using your API client information, imported into IntelliJ or Eclipse, and run on a local development server using Maven.\u003c/p\u003e\n"],["\u003cp\u003eA deployable WAR file can be built using Maven for production deployment.\u003c/p\u003e\n"],["\u003cp\u003eA fully-working demo is available at \u003ca href=\"https://glass-java-starter-demo.appspot.com\"\u003ehttps://glass-java-starter-demo.appspot.com\u003c/a\u003e.\u003c/p\u003e\n"]]],[],null,["# Java Quick Start\n\nThis project shows you how to implement a simple\npiece of Glassware that demos the major functionality of the Google Mirror API.\n\nTo see a fully-working demo of the quick start project, go to\n[https://glass-python-starter-demo.appspot.com](https://glass-java-starter-demo.appspot.com).\nOtherwise, read on to see how to deploy your own version.\n\n[Download on GitHub](https://github.com/googleglass/mirror-quickstart-java)\n\nPrerequisites\n-------------\n\nEnsure your system meets the following prerequisites for the quick start project:\n\n- Java 1.6\n- [Apache Maven](http://maven.apache.org/) - used for part of the build process.\n\nCreating a Google APIs Console project\n--------------------------------------\n\nNext, enable access to the Google Mirror API:\n\n1. Go to the [Google APIs console](https://code.google.com/apis/console/) and create a new API project.\n2. Click **Services** and enable the Google Mirror API for your new project.\n3. Click **API Access** and create an OAuth 2.0 client ID for a web application.\n4. Specify the product name and icon for your Glassware. These fields appear on the OAuth grant screen presented to your users.\n5. Select **Web application** and specify any value for the hostname, such as `localhost`\n6. Click **Edit settings...** for the client ID to specify redirect URIs. Specify the callback URLs for your local development web server, for example `http://localhost:8080/oauth2callback`, and for your deployed web server, for example `https://example.com/oauth2callback`.\n7. Make note of the client ID and secret from the Google APIs Console. You'll need it to configure the quick start project.\n\nConfiguring the Quick Start project\n-----------------------------------\n\nConfigure the Quick Start project to use your API client information by entering your client ID and\nsecret into `src/main/resources/oauth.properties`: \n\n # Replace these with values for your project from the Google API Console:\n # https://developers.google.com/console\n\n client_id=3141592653589793238462643383279\n client_secret=ITS_A_SECRET_TO_EVERYBODY\n\nImporting the project\n---------------------\n\nThe following instructions show you to import the Quick Start project source into IntelliJ and\nEclipse.\n\n### IntelliJ\n\n1. Click **File \\\u003e Import Project...**.\n2. Point to the extracted directory.\n3. Select **Import from existing model \\\u003e Maven**\n\n### Eclipse\n\n1. Install the [`m2e`](http://eclipse.org/m2e/) plugin to enable import from a maven pom file.\n2. Click **File \\\u003e Import... \\\u003e Maven \\\u003e Existing Maven Project**.\n3. Point to the extracted directory and import the project.\n\nRunning a local development server\n----------------------------------\n\nYou can run the Quick Start project on a local development server for testing: \n\n $ mvn jetty:run\n\nDeploying the Quick Start project\n---------------------------------\n\nYou can build a war file for this project using Maven: \n\n $ mvn war:war"]]