摘自: 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. Shell Python 日期和时间戳的互相转换

    一.初衷: 很多时候,时间的存储都是时间戳格式,如果需要展示就要转化成标准格式日期.也许会需要date和timestamp互转. 二.方法: 1.Shell下对date和timestamp的互转,是通 ...

  2. python(19)编码问题

    转载链接:http://blog.csdn.net/lxdcyh/article/details/4018054 python的编码问题,一直都让人很头疼,今天就整理下python的编码知识. 首先: ...

  3. 类(class)、构造函数(constructor)、原型(prototype)

    类 Class 类的概念应该是面向对象语言的一个特色,但是JavaScript并不像Java,C++等高级语言那样拥有正式的类,而是多数通过构造器以及原型方式来仿造实现.在讨论构造器和原型方法前,我可 ...

  4. JQuery之DataTables强大的表格解决方案

    1.DataTables的默认配置 $(document).ready(function() { $('#example').dataTable(); } ); 示例:http://www.guoxk ...

  5. eclipse快速收缩展开代码

    快速折叠所有代码和展开所有代码都是CTRL+SHIFT+/

  6. 写代码的自动提示是怎么出来的...我的WebStorm中不能自动提示Bootstrap中的样式呢

    首先开启自动提示 File -> Settings ->Editor ->Code Completion ->Preselect the first suggestion:,将 ...

  7. ajaxSubmit中option的参数

    var options = { target: '#output1', // target element(s) to be updated with server response beforeSu ...

  8. git向gitHub上push和pull数据.

    1.在gitHub上首先建立仓储.这个过程就不在啰嗦了. 2.注意上图中右下角的https,ssh等东西. 3.向git上传的工具特别多.我这里用的cygwin. 至于cygwin自己到网上去下载.安 ...

  9. [HDU 5090] Game with Pearls (贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5090 题目大意:给你n个数,问你给若干个数增加c*k(c>=0)能否组成1,2,3,4,5,.. ...

  10. VS打包资源文件,转自推酷,请小星同学查看

    上篇博客把收费系统的总体设计进行了一遍讲解,讲解的同时掺杂了些有关.NET编译机制的总结.程序编写测试完成后接下来我们要做的是打包部署程序,但VS2012让人心痛的是没有了打包工具.不知道出于什么原因 ...