Groovy安装与入门实例
摘自: 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安装与入门实例的更多相关文章
- flume安装及入门实例
1. 如何安装? 1)将下载的flume包,解压到/home/hadoop目录中 2)修改 flume-env.sh 配置文件,主要是JAVA_HOME变量设置 root@m1:/home/hadoo ...
- Eclipse安装springsource-tool-suite插件及spring helloworld入门实例
转载至: https://www.cnblogs.com/aaron-shu/p/5156007.html 一.查看eclipse版本 Help-->About Eclipse,我的版本是4.4 ...
- Apache Hadoop2.x 边安装边入门
完整PDF版本:<Apache Hadoop2.x边安装边入门> 目录 第一部分:Linux环境安装 第一步.配置Vmware NAT网络 一. Vmware网络模式介绍 二. NAT模式 ...
- Vue.js2.0从入门到放弃---入门实例
最近,vue.js越来越火.在这样的大浪潮下,我也开始进入vue的学习行列中,在网上也搜了很多教程,按着教程来做,也总会出现这样那样的问题(坑啊,由于网上那些教程都是Vue.js 1.x版本的,现在用 ...
- Spark+ECLIPSE+JAVA+MAVEN windows开发环境搭建及入门实例【附详细代码】
http://blog.csdn.net/xiefu5hh/article/details/51707529 Spark+ECLIPSE+JAVA+MAVEN windows开发环境搭建及入门实例[附 ...
- SoapUI简介和入门实例解析
SoapUI简介 SoapUI是一个开源测试工具,通过soap/http来检查.调用.实现Web Service的功能/负载/符合性测试.该工具既可作为一个单独的测试软件使用,也可利用插件集成到Ecl ...
- robotframework安装及入门指南
将很久之前自己在本地记录的一些笔记发表到随笔来,希望能够帮到一些童鞋~ robotframework安装及入门指南 本文主要介绍robotframework在windows环境的安装过程! 安装步骤 ...
- SpringMVC 框架系列之初识与入门实例
微信公众号:compassblog 欢迎关注.转发,互相学习,共同进步! 有任何问题,请后台留言联系! 1.SpringMVC 概述 (1). MVC:Model-View-Control Contr ...
- pytest_01_安装和入门
目录 pytest 安装与入门 1.pip install -U pytest 2.创建一个test01.py的文件 3.在该目录下执行pytest(venv) 4.执行多个,新建一个py文件 tes ...
随机推荐
- HTML5 Web Storage概述
Web Storage html5新增功能 可以在客户端本地保存数据 之前是使用Cookies在客户端保存注入用户名等简单用户信息,但永久数据存在几个问题 大小:cookies大小被限制在4KB 带宽 ...
- R-S触发器
下面是触发器的电路,这个电路上下对称,分别都是一个或门连着一个非门,特别之处在于,它们各自的输出又分别是对方的输入. 合上R,上面的或门输入时1.0,经过上面的非门,Q=0,Q不发光.Q的结果会被反馈 ...
- SDcard进行文件的读取
平时我们需要在手机上面存储想音频,视频等等的大文件,以前学过使用File进行存储(使用File操作进行存储):由于考虑到手机本身的存储空间小,这时候我们需要把文件存储在SDcard中,今天自己也学习了 ...
- You need tcl 8.5 or newer in order to run the Redis test
安装Redis时候make test出现的 , 不用下什么tcl8.5再tar了 , 直接yum install tcl就好.
- 值不能为 null 或为空。参数名: linkText
“/”应用程序中的服务器错误. 值不能为 null 或为空.参数名: linkText 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的 ...
- js 事件函数中的参数带换行符或换行标签都不能起作用的解决方法
把问题参数值赋给标签的属性data-value,通过属性值获取参数值.
- HTTP 1.1与HTTP 1.0的比较
HTTP 1.1与HTTP 1.0的比较 一个WEB站点每天可能要接收到上百万的用户请求,为了提高系统的效率,HTTP 1.0规定浏览器与服务器只保持短暂的连接,浏览器的每次请求都需要与服务器建立一个 ...
- git相关网页
git.apache2.gerrit安装 1.http://blog.csdn.net/benkaoya/article/details/8680886 2.http://fatalove.iteye ...
- 在每次request请求时变化session
session.invalidate();//使得当前的session失效 request.getSession(true).getId();//生成一个新的session 原理: request.g ...
- [ActionScript 3.0] LocalConnection示例
下例包含两个 ActionScript 类,这两个类应当编译到两个单独的 SWF 文件中: 在 LocalConnectionSenderExample SWF 文件中,将创建 LocalConnec ...