摘自: 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. [MySQL] 常用SQL的优化--18.4

    这里介绍下,Insert.Group By等SQL语句的优化方法: 1.大批量数据插入 当load命令导入数据的时候,可以进行适当的设置提高导入速度. 1.1 对于MyISAM表,可以先禁用非唯一索引 ...

  2. 问对于一个给定的n,怎样才能用最少的步骤将它变到1

    如果n为偶数,则将它除以2,如果n为奇数,则将它加1或者减1.问对于一个给定的n,怎样才能用最少的步骤将它变到1.例如:n= 61n-- 60n/2 30n/2 15n++ 16n/2 8n/2 4n ...

  3. unity jiaoben

    transform.Translate(Input.GetAxis("Horizontal")*Time.deltaTime,0,0); 移动 transform.Translat ...

  4. 在eclipse中下载包含子模块(Submodules)的git项目

    先将项目下载下来 , 这时由于是子项目的原因 , 下载的项目中不包含任何子项目 . 这时在eclipse的Git Repositories中 , 选中Submodules , 右键点击update即可 ...

  5. SVN---脱离SVN控制

    创建一个记事本文件,然后吧这句话复制进去for /r . %%a in (.) do @if exist "%%a\.svn" rd /s /q "%%a\.svn&qu ...

  6. ubuntu vnc install

    windows & ubuntu http://www.jb51.net/os/Ubuntu/104948.html ubuntu & ubuntu https://www.digit ...

  7. compass项目监控文件报 /usr/bin/env 找不到文件

    1 找到ruby执行文件目录 $ wherris ruby ruby: /usr/lib/ruby /home/rudy/.rbenv/shims/ruby 2 设置软链接 sudo ln -s /h ...

  8. 解决Ubuntu不能挂载ntfs格式硬盘

    以前都是自动可以挂在NTFS硬盘的,可是现在不能挂载了.搜了一下 这里有办法 http://forum.ubuntu.org.cn/viewtopic.php?t=313930 例如你是 Error ...

  9. git撤销命令

    1 撤销工作区中master的修改 git checkout -- master.txt ,用暂存去覆盖工作区 2 git clean -n 查看哪些文件会被移除3 git clean -f 强制删除 ...

  10. 在每次request请求时变化session

    session.invalidate();//使得当前的session失效 request.getSession(true).getId();//生成一个新的session 原理: request.g ...