摘自: http://blog.csdn.net/dc_726/article/details/8576205

1 Groovy是什么?

来看下官网的介绍:http://groovy.codehaus.org

Groovy...

· is an agile and dynamic language for the Java Virtual Machine

· builds upon the strengths of Javabut has additionalpower features inspiredby languages like Python, Ruby and Smalltalk

· makes modern programming features available to Java developers with almost-zero learning curve

· provides the ability to statically type check and staticallycompile your codefor robustness and performance

· supports Domain-Specific Languages and other compact syntax so your codebecomes easyto read and maintain

· makes writing shell and buildscripts easy with its powerfulprocessing primitives, OO abilities and an Ant DSL

· increases developer productivity by reducing scaffolding code when developing web, GUI, database orconsole applications

· simplifies testing bysupporting unit testing and mocking out-of-the-box

· seamlessly integrates with all existingJava classes and libraries

· compiles straight to Java bytecodeso you can use it anywhere you can use Java

通过支持DSL提高代码可读性和可维护性

减少开始Web、GUI、数据库、控制台应用程序时的脚手架代码

简化单元测试和Mock技术

与Java类包无缝集成

2 Groovy环境安装

下面是官方文档中摘取的安装步骤。适用于Linux系统或Cygwin模拟环境。如果是Windows平台的话,也可以直接下载Windows installer一键安装。

GVM (the GroovyenVironment Manager)

This tool makesinstalling Groovy on any Bash platform (Mac OSX, Linux, Cygwin, Solaris orFreeBSD) very easy.

Simply open a newterminal and enter:

$ curl -s get.gvmtool.net | bash

Follow theinstructions on-screen to complete installation.

Open a newterminal or type the command:

$ source "$HOME/.gvm/bin/gvm-init.sh"

Then install thelatest stable Groovy:

$ gvm install groovy

After installationis complete and you've made it your default version, test it with:

$ groovy -version

That's all thereis to it!

下面来亲自体验一下,然后编写个Groovy版的Hello World测试一下。

$ curl –s get.gvmtool.net | bash

之后执行初始化脚本,也可以将这句命令加入到~/.bashrc中。

$ source "/cygdrive/c/Users/daichen/.gvm/bin/gvm-init.sh"

编写一个Hello World试一下吧。

helloworld.groovy

class Test {

def text = “helloworld!!!”

}

print new Test().getText()

     $ groovy helloworld.groovy
hello world!!!

3 Groovy-Eclipse插件安装

在Help -> Install New Software下输入http://dist.springsource.org/release/GRECLIPSE/e3.6

选择Groovy-Eclipse (Required) 进行安装。

可以新建Groovy项目,或者在已有项目中新加Groovy Class,就会自动开启此项目上的Groovy Nature属性。这样普通Java代码就与Groovy代码融合在一起了。

Groovy安装与入门实例的更多相关文章

  1. flume安装及入门实例

    1. 如何安装? 1)将下载的flume包,解压到/home/hadoop目录中 2)修改 flume-env.sh 配置文件,主要是JAVA_HOME变量设置 root@m1:/home/hadoo ...

  2. Eclipse安装springsource-tool-suite插件及spring helloworld入门实例

    转载至: https://www.cnblogs.com/aaron-shu/p/5156007.html 一.查看eclipse版本 Help-->About Eclipse,我的版本是4.4 ...

  3. Apache Hadoop2.x 边安装边入门

    完整PDF版本:<Apache Hadoop2.x边安装边入门> 目录 第一部分:Linux环境安装 第一步.配置Vmware NAT网络 一. Vmware网络模式介绍 二. NAT模式 ...

  4. Vue.js2.0从入门到放弃---入门实例

    最近,vue.js越来越火.在这样的大浪潮下,我也开始进入vue的学习行列中,在网上也搜了很多教程,按着教程来做,也总会出现这样那样的问题(坑啊,由于网上那些教程都是Vue.js 1.x版本的,现在用 ...

  5. Spark+ECLIPSE+JAVA+MAVEN windows开发环境搭建及入门实例【附详细代码】

    http://blog.csdn.net/xiefu5hh/article/details/51707529 Spark+ECLIPSE+JAVA+MAVEN windows开发环境搭建及入门实例[附 ...

  6. SoapUI简介和入门实例解析

    SoapUI简介 SoapUI是一个开源测试工具,通过soap/http来检查.调用.实现Web Service的功能/负载/符合性测试.该工具既可作为一个单独的测试软件使用,也可利用插件集成到Ecl ...

  7. robotframework安装及入门指南

    将很久之前自己在本地记录的一些笔记发表到随笔来,希望能够帮到一些童鞋~ robotframework安装及入门指南 本文主要介绍robotframework在windows环境的安装过程! 安装步骤 ...

  8. SpringMVC 框架系列之初识与入门实例

    微信公众号:compassblog 欢迎关注.转发,互相学习,共同进步! 有任何问题,请后台留言联系! 1.SpringMVC 概述 (1). MVC:Model-View-Control Contr ...

  9. pytest_01_安装和入门

    目录 pytest 安装与入门 1.pip install -U pytest 2.创建一个test01.py的文件 3.在该目录下执行pytest(venv) 4.执行多个,新建一个py文件 tes ...

随机推荐

  1. 白书 4.1.2 模运算的世界 P291

    1.逆元 这里有个注意事项要说,就是当要求 (a-b)%m 的时候要注意不能直接 (a%m-b%m)%m 原因是得出的值有可能是负数,所以 (a%m-b%m+m)%m 才是正确的. //x,y是引用 ...

  2. js复习(二)

    一.window.document对象(一)找元素 docunment.getElementById("id"):根据id找,最多找一个: docunment.getElement ...

  3. image和字节流之间的相互转换

    //将图片转化为长二进制 public Byte[] SetImgToByte(string imgPath) { FileStream file = new FileStream(imgPath, ...

  4. Cassandra安装及其简单试用

    官方主页:http://cassandra.apache.org/ 简介: The Apache Cassandra Project develops a highly scalable second ...

  5. 深入ThreadLocal之一

    想必很多朋友对ThreadLocal并不陌生,今天我们就来一起探讨下ThreadLocal的使用方法和实现原理.首先,本文先谈一下对ThreadLocal的理解,然后根据ThreadLocal类的源码 ...

  6. $.extend()和$.fn.extend()用法和区别

    $.extend()和$.fn.extend()用法和区别: 在自己制作插件的时候会经常用到$.extend()和$.fn.extend()两个函数,无论从外观还是作用都非常的类似,但是实际上它们的区 ...

  7. Windows下Nginx的启动、停止等命令(转)

    Windows下Nginx的启动.停止等命令 在Windows下使用Nginx,我们需要掌握一些基本的操作命令,比如:启动.停止Nginx服务,重新载入Nginx等,下面我就进行一些简单的介绍.1.启 ...

  8. NYOJ 49-开心的小明:01背包

    点击打开链接 开心的小明 时间限制:1000 ms  |  内存限制:65535 KB 难度:4 描述 小明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间.更让他高兴的是 ...

  9. Remove Duplicates from Sorted List(链表)

    Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...

  10. 部署windows服务

    (1) cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319(2) InstallUtil.exe D:\SVN\zhongchao\开发\WeiXin ...