Spring Cloud Google Cloud는 Spring 애플리케이션에서 Vision API와 연동할 수 있는 편리한 라이브러리를 제공합니다. 이러한 라이브러리에는 개발자가 Vision API를 빠르게 시작할 수 있도록 자동 구성 및 도우미 클래스와 Spring Boot Template 클래스가 포함되어 있습니다.
Spring Framework에 이미 익숙한 사용자라면 Spring Cloud Vision을 통해 애플리케이션에서 Vision API 관련 작업을 간편하게 수행하고 작성해야 하는 코드의 양을 줄일 수 있습니다.
이 페이지에서는 자바 애플리케이션에 Spring Cloud Vision을 추가하는 방법을 설명합니다. 모듈에 대한 자세한 내용은 Spring Cloud Vision 참조를 확인하세요.
종속 항목 설정
이 라이브러리 사용을 시작하려면 프로젝트에 spring-cloud-gcp-starter-vision 아티팩트를 추가합니다.
CloudVisionTemplate은 Vision API 클라이언트 라이브러리를 둘러싸는 래퍼로, Vision API를 통해 이미지를 쉽게 처리할 수 있습니다.
CloudVisionTemplate 기능에 대한 자세한 내용은 Cloud Vision 템플릿 참조 페이지를 확인하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-16(UTC)"],[],[],null,["# Using Vision with Spring framework\n\n[Spring Cloud Google Cloud](https://spring.io/projects/spring-cloud-gcp) offers convenient libraries\nto interface with the Vision API from a Spring application. These libraries\ninclude\n[Auto-Configuration and helper classes](https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-auto-configuration.html)\nand Spring Boot Template classes to allow developers to get started\nwith the Vision API quickly.\n\nIf you're already familiar with the\n[Spring Framework](https://spring.io/projects/spring-framework), then\nSpring Cloud Vision can\nmake it easier to work with the Vision API in your application and\nreduce the amount of code that you need to write.\n\nThis page explains how to add Spring Cloud Vision to a Java\napplication. For detailed information about the module, see the\n[Spring Cloud Vision reference](https://googlecloudplatform.github.io/spring-cloud-gcp/4.1.3/reference/html/index.html#cloud-vision).\n\nDependency setup\n----------------\n\nTo begin using this library, add the `spring-cloud-gcp-starter-vision` artifact\nto your project.\n\nMaven coordinates, using Spring Cloud Google Cloud BOM: \n\n \u003cdependencyManagement\u003e\n \u003cdependencies\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003eorg.springframework.cloud\u003c/groupId\u003e\n \u003cartifactId\u003espring-cloud-gcp-dependencies\u003c/artifactId\u003e\n \u003cversion\u003e1.2.8.RELEASE\u003c/version\u003e\n \u003ctype\u003epom\u003c/type\u003e\n \u003cscope\u003eimport\u003c/scope\u003e\n \u003c/dependency\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n \u003cartifactId\u003espring-boot-dependencies\u003c/artifactId\u003e\n \u003cversion\u003e${spring.version}\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 \u003cdependency\u003e\n \u003cgroupId\u003eorg.springframework.cloud\u003c/groupId\u003e\n \u003cartifactId\u003espring-cloud-gcp-starter-vision\u003c/artifactId\u003e\n \u003c/dependency\u003e\n\nFor more information, see the instructions for [setting up a Java development\nenvironment](/java/docs/setup). You do not need to install the Google Cloud Client\nLibrary for Java; the Spring Boot starter installs the client library\nautomatically.\n\nImage analysis\n--------------\n\nAfter configuring the Spring Cloud Google Cloud Vision dependencies on your\nclasspath, you can immediately begin processing your images by getting\nan instance of `CloudVisionTemplate` using [Spring dependency injection](https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-spring-beans-and-dependency-injection.html). \n\n @Autowired private CloudVisionTemplate cloudVisionTemplate;\n\nThe `CloudVisionTemplate` is a wrapper around the Vision API\nClient Libraries and lets you process images easily through the\nVision API.\nFor more information about the `CloudVisionTemplate` features, see\nthe [Cloud Vision template reference page](https://googlecloudplatform.github.io/spring-cloud-gcp/4.1.3/reference/html/index.html#cloud-vision).\n\nThe following sections contain code samples for common use cases of\nthe `CloudVisionTemplate`. All code snippets come from the [Spring and\nCloud Vision sample application](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/vision/spring-framework).\n\n### Getting the classification labels for an image\n\nThe code below extracts the classification labels for an image, providing you\nwith general descriptions of image content. \n\n AnnotateImageResponse response =\n this.cloudVisionTemplate.analyzeImage(\n this.resourceLoader.getResource(imageUrl), Type.LABEL_DETECTION);\n\n Map\u003cString, Float\u003e imageLabels =\n response.getLabelAnnotationsList().stream()\n .collect(\n Collectors.toMap(\n EntityAnnotation::getDescription,\n EntityAnnotation::getScore,\n (u, v) -\u003e {\n throw new IllegalStateException(String.format(\"Duplicate key %s\", u));\n },\n LinkedHashMap::new));\n\n### Extracting the Text In an Image\n\nThe code sample below describes another common operation of extracting the text\nfrom an image. \n\n String textFromImage =\n this.cloudVisionTemplate.extractTextFromImage(this.resourceLoader.getResource(imageUrl));\n return \"Text from image: \" + textFromImage;\n\nWhat's next\n-----------\n\n- [Get started with\n Spring Cloud Google Cloud](https://googlecloudplatform.github.io/spring-cloud-gcp/4.1.3/reference/html/index.html#getting-started).\n- Learn more about [using Spring Cloud Vision in your\n applications](https://googlecloudplatform.github.io/spring-cloud-gcp/4.1.3/reference/html/index.html#cloud-vision).\n- [File a GitHub issue](https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues) to report a bug or ask a question about the module.\n- Get more information about [Spring Framework support on\n Google Cloud](/java/docs/reference/spring).\n- Try a codelab to [deploy and run an application that uses\n Spring Cloud Google Cloud](https://codelabs.developers.google.com/spring/)."]]