21 lines
3.8 KiB
HTML
21 lines
3.8 KiB
HTML
<html><head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>3. Writing Groovy Scripts and Running Applications</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud-cli.html" title="Spring Boot Cloud CLI"><link rel="up" href="multi_spring-cloud-cli.html" title="Spring Boot Cloud CLI"><link rel="prev" href="multi__running_spring_cloud_services_in_development.html" title="2. Running Spring Cloud Services in Development"><link rel="next" href="multi__encryption_and_decryption.html" title="4. Encryption and Decryption"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3. Writing Groovy Scripts and Running Applications</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__running_spring_cloud_services_in_development.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__encryption_and_decryption.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_writing_groovy_scripts_and_running_applications" href="#_writing_groovy_scripts_and_running_applications"></a>3. Writing Groovy Scripts and Running Applications</h1></div></div></div><p>Spring Cloud CLI has support for most of the Spring Cloud declarative
|
|
features, such as the <code class="literal">@Enable*</code> class of annotations. For example,
|
|
here is a fully functional Eureka server</p><p><b>app.groovy. </b>
|
|
</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@EnableEurekaServer</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> Eureka {}</pre><p>
|
|
</p><p>which you can run from the command line like this</p><pre class="screen">$ spring run app.groovy</pre><p>To include additional dependencies, often it suffices just to add the
|
|
appropriate feature-enabling annotation, e.g. <code class="literal">@EnableConfigServer</code>,
|
|
<code class="literal">@EnableOAuth2Sso</code> or <code class="literal">@EnableEurekaClient</code>. To manually include a
|
|
dependency you can use a <code class="literal">@Grab</code> with the special "Spring Boot" short
|
|
style artifact co-ordinates, i.e. with just the artifact ID (no need
|
|
for group or version information), e.g. to set up a client app to
|
|
listen on AMQP for management events from the Spring CLoud Bus:</p><p><b>app.groovy. </b>
|
|
</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@Grab('spring-cloud-starter-bus-amqp')</span></em>
|
|
<em><span class="hl-annotation" style="color: gray">@RestController</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> Service {
|
|
<em><span class="hl-annotation" style="color: gray">@RequestMapping('/')</span></em>
|
|
def home() { [message: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Hello'</span>] }
|
|
}</pre><p>
|
|
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__running_spring_cloud_services_in_development.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__encryption_and_decryption.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2. Running Spring Cloud Services in Development </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-cli.html">Home</a></td><td width="40%" align="right" valign="top"> 4. Encryption and Decryption</td></tr></table></div></body></html> |