Files
spring-cloud-static/spring-cloud-gcp/1.2.0.M3/reference/html/getting-started.html
2019-10-03 21:44:47 +00:00

390 lines
19 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 1.5.7.1">
<title>Getting Started</title>
<link rel="stylesheet" href="css/spring.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
.hidden {
display: none;
}
.switch {
border-width: 1px 1px 0 1px;
border-style: solid;
border-color: #7a2518;
display: inline-block;
}
.switch--item {
padding: 10px;
background-color: #ffffff;
color: #7a2518;
display: inline-block;
cursor: pointer;
}
.switch--item:not(:first-child) {
border-width: 0 0 0 1px;
border-style: solid;
border-color: #7a2518;
}
.switch--item.selected {
background-color: #7a2519;
color: #ffffff;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js"></script>
<script type="text/javascript">
function addBlockSwitches() {
$('.primary').each(function() {
primary = $(this);
createSwitchItem(primary, createBlockSwitch(primary)).item.addClass("selected");
primary.children('.title').remove();
});
$('.secondary').each(function(idx, node) {
secondary = $(node);
primary = findPrimary(secondary);
switchItem = createSwitchItem(secondary, primary.children('.switch'));
switchItem.content.addClass('hidden');
findPrimary(secondary).append(switchItem.content);
secondary.remove();
});
}
function createBlockSwitch(primary) {
blockSwitch = $('<div class="switch"></div>');
primary.prepend(blockSwitch);
return blockSwitch;
}
function findPrimary(secondary) {
candidate = secondary.prev();
while (!candidate.is('.primary')) {
candidate = candidate.prev();
}
return candidate;
}
function createSwitchItem(block, blockSwitch) {
blockName = block.children('.title').text();
content = block.children('.content').first().append(block.next('.colist'));
item = $('<div class="switch--item">' + blockName + '</div>');
item.on('click', '', content, function(e) {
$(this).addClass('selected');
$(this).siblings().removeClass('selected');
e.data.siblings('.content').addClass('hidden');
e.data.removeClass('hidden');
});
blockSwitch.append(item);
return {'item': item, 'content': content};
}
$(addBlockSwitches);
</script>
</head>
<body class="book toc2 toc-left">
<div id="header">
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
<ul class="sectlevel1">
<li><a href="#_getting_started">Getting Started</a>
<ul class="sectlevel2">
<li><a href="#_setting_up_dependencies">Setting up Dependencies</a></li>
<li><a href="#_learning_spring_cloud_gcp">Learning Spring Cloud GCP</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="content">
<div class="sect1">
<h2 id="_getting_started"><a class="link" href="#_getting_started">Getting Started</a></h2>
<div class="sectionbody">
<div class="paragraph">
<p>This section describes how to get up to speed with Spring Cloud GCP libraries.</p>
</div>
<div class="sect2">
<h3 id="_setting_up_dependencies"><a class="link" href="#_setting_up_dependencies">Setting up Dependencies</a></h3>
<div class="paragraph">
<p>All Spring Cloud GCP artifacts are made available through Maven Central.
The following resources are provided to help you setup the libraries for your project:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Maven Bill of Materials for dependency management</p>
</li>
<li>
<p>Starter Dependencies for depending on Spring Cloud GCP modules</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>You may also consult our <a href="https://github.com/spring-cloud/spring-cloud-gcp">Github project</a> to examine the code or build directly from source.</p>
</div>
<div class="sect3">
<h4 id="_bill_of_materials"><a class="link" href="#_bill_of_materials">Bill of Materials</a></h4>
<div class="paragraph">
<p>The Spring Cloud GCP Bill of Materials (BOM) contains the versions of all the dependencies it uses.</p>
</div>
<div class="paragraph">
<p>If youre a Maven user, adding the following to your pom.xml file will allow you omit any Spring Cloud GCP dependency version numbers from your configuration.
Instead, the version of the BOM youre using determines the versions of the used dependencies.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml">&lt;dependencyManagement&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
&lt;artifactId&gt;spring-cloud-gcp-dependencies&lt;/artifactId&gt;
&lt;version&gt;1.2.0.M3&lt;/version&gt;
&lt;type&gt;pom&lt;/type&gt;
&lt;scope&gt;import&lt;/scope&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;/dependencyManagement&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>See the <a href="#README.adoc">sections</a> in the README for selecting an available version and Maven repository.</p>
</div>
<div class="paragraph">
<p>In the following sections, it will be assumed you are using the Spring Cloud GCP BOM and the dependency snippets will not contain versions.</p>
</div>
<div class="paragraph">
<p>Gradle users can achieve the same kind of BOM experience using Spring&#8217;s <a href="https://github.com/spring-gradle-plugins/dependency-management-plugin">dependency-management-plugin</a> Gradle plugin.
For simplicity, the Gradle dependency snippets in the remainder of this document will also omit their versions.</p>
</div>
</div>
<div class="sect3">
<h4 id="_starter_dependencies"><a class="link" href="#_starter_dependencies">Starter Dependencies</a></h4>
<div class="paragraph">
<p>Spring Cloud GCP offers <a href="https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-starters">starter dependencies</a> through Maven to easily depend on different modules of the library.
Each starter contains all the dependencies and transitive dependencies needed to begin using their corresponding Spring Cloud GCP module.</p>
</div>
<div class="paragraph">
<p>For example, if you wish to write a Spring application with Cloud Pub/Sub, you would include the <code>spring-cloud-gcp-starter-pubsub</code> dependency in your project.
You do <strong>not</strong> need to include the underlying <code>spring-cloud-gcp-pubsub</code> dependency, because the <code>starter</code> dependency includes it.</p>
</div>
<div class="paragraph">
<p>A summary of these artifacts are provided below.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Spring Cloud GCP Starter</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Maven Artifact Name</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Core</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Automatically configure authentication and Google project settings</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="core.html#spring-cloud-gcp-core">org.springframework.cloud:spring-cloud-gcp-starter</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cloud Spanner</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Provides integrations with Google Cloud Spanner</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="spanner.html#_spring_data_cloud_spanner">org.springframework.cloud:spring-cloud-gcp-starter-data-spanner</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cloud Datastore</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Provides integrations with Google Cloud Datastore</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="datastore.html#_spring_data_cloud_datastore">org.springframework.cloud:spring-cloud-gcp-starter-data-datastore</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cloud Pub/Sub</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Provides integrations with Google Cloud Pub/Sub</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="pubsub.html#_google_cloud_pubsub">org.springframework.cloud:spring-cloud-gcp-starter-pubsub</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Logging</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Enables Stackdriver Logging</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="logging.html#_stackdriver_logging">org.springframework.cloud:spring-cloud-gcp-starter-logging</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">SQL - MySQL</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cloud SQL integrations with MySQL</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="sql.html#_spring_jdbc">org.springframework.cloud:spring-cloud-gcp-starter-sql-mysql</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">SQL - PostgreSQL</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cloud SQL integrations with PostgreSQL</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="sql.html#_spring_jdbc">org.springframework.cloud:spring-cloud-gcp-starter-sql-postgresql</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Storage</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Provides integrations with Google Cloud Storage and Spring Resource</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="storage.html#_spring_resources">org.springframework.cloud:spring-cloud-gcp-starter-storage</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Config</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Enables usage of Google Runtime Configuration API as a Spring Cloud Config server</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="config.html#_spring_cloud_config">org.springframework.cloud:spring-cloud-gcp-starter-config</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Trace</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Enables instrumentation with Google Stackdriver Tracing</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="trace.html#_spring_cloud_sleuth">org.springframework.cloud:spring-cloud-gcp-starter-trace</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Vision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Provides integrations with Google Cloud Vision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="vision.html#_google_cloud_vision">org.springframework.cloud:spring-cloud-gcp-starter-vision</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Security - IAP</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Provides a security layer over applications deployed to Google Cloud</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="security-iap.html#_cloud_identity_aware_proxy_iap_authentication">org.springframework.cloud:spring-cloud-gcp-starter-security-iap</a></p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="_spring_initializr"><a class="link" href="#_spring_initializr">Spring Initializr</a></h4>
<div class="paragraph">
<p><a href="https://start.spring.io/">Spring Initializr</a> is a tool which generates the scaffolding code for a new Spring Boot project.
It handles the work of generating the Maven or Gradle build file so you do not have to manually add the dependencies yourself.</p>
</div>
<div class="paragraph">
<p>Spring Initializr offers three modules from Spring Cloud GCP that you can use to generate your project.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>GCP Support</strong>: The GCP Support module contains auto-configuration support for every Spring Cloud GCP integration.
Most of the autoconfiguration code is only enabled if the required dependency is added to your project.</p>
</li>
<li>
<p><strong>GCP Messaging</strong>: Google Cloud Pub/Sub integrations work out of the box.</p>
</li>
<li>
<p><strong>GCP Storage</strong>: Google Cloud Storage integrations work out of the box.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_learning_spring_cloud_gcp"><a class="link" href="#_learning_spring_cloud_gcp">Learning Spring Cloud GCP</a></h3>
<div class="paragraph">
<p>There are a variety of resources to help you learn how to use Spring Cloud GCP libraries.</p>
</div>
<div class="sect3">
<h4 id="_sample_applications"><a class="link" href="#_sample_applications">Sample Applications</a></h4>
<div class="paragraph">
<p>The easiest way to learn how to use Spring Cloud GCP is to consult the <a href="https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples">sample applications on Github</a>.
Spring Cloud GCP provides sample applications which demonstrate how to use every integration in the library.
The table below highlights several samples of the most commonly used integrations in Spring Cloud GCP.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">GCP Integration</th>
<th class="tableblock halign-left valign-top">Sample Application</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cloud Pub/Sub</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples/spring-cloud-gcp-pubsub-sample">spring-cloud-gcp-pubsub-sample</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cloud Spanner</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples/spring-cloud-gcp-data-spanner-sample">spring-cloud-gcp-data-spanner-sample</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Datastore</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples/spring-cloud-gcp-data-datastore-sample">spring-cloud-gcp-data-datastore-sample</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cloud SQL (w/ MySQL)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples/spring-cloud-gcp-sql-mysql-sample">spring-cloud-gcp-sql-mysql-sample</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cloud Storage</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples/spring-cloud-gcp-storage-resource-sample">spring-cloud-gcp-storage-resource-sample</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Stackdriver Logging</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples/spring-cloud-gcp-logging-sample">spring-cloud-gcp-logging-sample</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Trace</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples/spring-cloud-gcp-trace-sample">spring-cloud-gcp-trace-sample</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cloud Vision</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples/spring-cloud-gcp-vision-api-sample">spring-cloud-gcp-vision-api-sample</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cloud Security - IAP</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples/spring-cloud-gcp-security-iap-sample">spring-cloud-gcp-security-iap-sample</a></p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Each sample application demonstrates how to use Spring Cloud GCP libraries in context and how to setup the dependencies for the project.
The applications are fully functional and can be deployed to Google Cloud Platform as well.
If you are interested, you may consult guides for <a href="https://codelabs.developers.google.com/codelabs/cloud-app-engine-springboot/index.html">deploying an application to AppEngine</a> and <a href="https://codelabs.developers.google.com/codelabs/cloud-springboot-kubernetes/index.html">to Google Kubernetes Engine</a>.</p>
</div>
</div>
<div class="sect3">
<h4 id="_codelabs"><a class="link" href="#_codelabs">Codelabs</a></h4>
<div class="paragraph">
<p>For a more hands-on approach, there are several guides and codelabs to help you get up to speed.
These guides provide step-by-step instructions for building an application using Spring Cloud GCP.</p>
</div>
<div class="paragraph">
<p>Some examples include:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://codelabs.developers.google.com/codelabs/cloud-app-engine-springboot/index.html">Deploy a Spring Boot app to App Engine</a></p>
</li>
<li>
<p><a href="https://codelabs.developers.google.com/codelabs/cloud-spring-cloud-gcp-kotlin/index.html">Build a Kotlin Spring Boot app with Cloud SQL and Cloud Pub/Sub</a></p>
</li>
<li>
<p><a href="https://codelabs.developers.google.com/codelabs/cloud-spring-datastore/index.html">Build a Spring Boot application with Datastore</a></p>
</li>
<li>
<p><a href="https://codelabs.developers.google.com/codelabs/cloud-spring-cloud-gcp-pubsub-integration/index.html">Messaging with Spring Integration and Cloud Pub/Sub</a></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The full collection of Spring codelabs can be found on the <a href="https://codelabs.developers.google.com/spring">Google Developer Codelabs page</a>.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/tocbot/tocbot.min.js"></script>
<script type="text/javascript" src="js/toc.js"></script>
<link rel="stylesheet" href="js/highlight/styles/atom-one-dark-reasonable.min.css">
<script src="js/highlight/highlight.min.js"></script>
<script>hljs.initHighlighting()</script>
</body>
</html>