Groovy入门-1

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013803499/article/details/54613968

Groovy 是 Java平台上脚本语言,抽象程度更高(可以更简单的快速开发,可以编写更少的代码)
与Java语言无缝集成,可称为“超级Java”
1.使用“类Java”语法,Java程序员可以快速过渡。
2.Groovy与Java二进制兼容,都可以生成字节码,所以可以与使用Java语言所编写的框架和组件完美集成,并且效率安全方面比其他脚本语言更高。
3.Groovy对象就是Java对象,使用与JDK相同的API.
4.可以保护整个Java产业在Java上的巨大投资。
在中小型项目中可以替代Java,在大型Java项目中可以嵌入Groovy应用。

Groovy的特征
Groovy = Java - 重复代码
+ 可选的动态类型
+ 闭包(closures)
+ 领域规范语言(DSL)
+ 生成器(builders)
+ 元编程(metaprogramming)
Groovy 是没有类型、修饰符、return、Iterator,不需要导入集合的Java。Groovy丢掉了许多Java的报复。
不能确定变量类型时将变量类型设为Object。
DSL:domain specific languages
生成器:可以生成XML/HTML/Swing树形数据结构
元编程:运行时对类增加行为,类似于AOP

由于idea有默认对Groovy的支持,这里就不多阐述Idea对于Groovy的使用,在这里阐述一下eclipse对Groovy的使用。

Eclipse-Groovy 插件

News
Date News
Mar 4, 2016 Groovy Eclipse snapshot builds for Eclipse 4.6 are available! Update site: http://dist.springsource.org/snapshot/GRECLIPSE/e4.6/
Jun 6, 2015 Groovy Eclipse 2.9.2 snapshot builds for Eclipse 4.5 are available, update site http://dist.springsource.org/snapshot/GRECLIPSE/e4.5/
Jan 24, 2015 Groovy Eclipse 2.9.2 snapshot builds for Eclipse 4.4 now include Groovy 2.4.0, update site http://dist.springsource.org/snapshot/GRECLIPSE/e4.4/ NOTE installing this will downgrade your Eclipse JDT because it does not include the latest version. This may introduce problems that have since been fixed in JDT. If you see any JDT issues try uninstalling this first to confirm whether it is really Eclipse that is to blame or the patched compiler in here
November 18, 2014 Groovy Eclipse 2.9.1 Released. This release includes support for the latest Groovy 2.3.7, improved to QuickFixes, type inference and other bug fixes. Read more in the [[Groovy Eclipse 2.9.1 Release Notes]]
July 17, 2014 Groovy Eclipse 2.9.0 Released. This release includes support for the latest Groovy 2.3.4 compiler with features such as Traits. Read more in the [[Groovy Eclipse 2.9.0 Release Notes]]
July 9, 2013 Groovy Eclipse 2.8.0 Released. This release includes significant memory and performance improvements, as well as Editor templates and almost 100 bugs fixed. Read more at the Groovy-Eclipse 2.8.0 New and Noteworthy.
Releases

The latest Groovy-Eclipse release is available from the following Eclipse update sites. To install, point your Eclipse update manager to the update site appropriate for your Eclipse version.
Eclipse Level Release Update Site
4.4 (Luna) http://dist.springsource.org/release/GRECLIPSE/e4.4/
4.3 (Kepler) http://dist.springsource.org/release/GRECLIPSE/e4.3/
4.3-8 (Kepler with Java 8) http://dist.springsource.org/release/GRECLIPSE/e4.3-j8/
4.2 and 3.8 (Juno) http://dist.springsource.org/release/GRECLIPSE/e4.2/
3.7 (Indigo) http://dist.springsource.org/release/GRECLIPSE/e3.7/

Or, you can choose to install a development build, see below for more update sites. In general, our development builds are quite stable.

The install directory must be writable by the current user. Groovy-Eclipse cannot be installed into a shared install. This includes protected directories on windows like C:\Program Files. For more information Eclipse Bug 395516.
Snapshot Builds

Use one of these update sites to install the latest and greatest Groovy-Eclipse. Development builds tend to be quite stable (they are not released unless all tests pass). To install, paste the appropriate update site below into your Eclipse update manager, select the artifacts to install and follow the instructions.
Eclipse Level Snapshot Update Site
4.6 (Neon) http://dist.springsource.org/snapshot/GRECLIPSE/e4.6/
4.5 (Mars) http://dist.springsource.org/snapshot/GRECLIPSE/e4.5/
4.4 (Luna) http://dist.springsource.org/snapshot/GRECLIPSE/e4.4/
4.3-j8 (Kepler with Java 8 patch) http://dist.springsource.org/snapshot/GRECLIPSE/e4.3-j8/
4.3 (Kepler) http://dist.springsource.org/snapshot/GRECLIPSE/e4.3/
4.2 and 3.8 (Juno) http://dist.springsource.org/snapshot/GRECLIPSE/e4.2/
3.7 (Indigo) http://dist.springsource.org/snapshot/GRECLIPSE/e4.2/
How to Install

Start with a compatible version of Eclipse (available from http://eclipse.org/downloads). Since Groovy-Eclipse relies on Eclipse’s Java tooling (the JDT), almost any flavor of Eclipse that includes the JDT will be compatible. This includes the Java IDE, Classic, RCP, JavaEE, etc. Flavors such as Eclipse for PHP developers are not compatible because it does not include the JDT> If you are interested in Grails tooling, then you must install the Groovy/Grails Tool Suite.

Once you have a compatible Eclipse installed, then follow these directions to install Groovy-Eclipse:

扫描二维码关注公众号,回复: 4358277 查看本文章
Go to: Help -> Software Updates.
Change to the Available Software tab.
Click on Add Site.
Paste the update site URL appropriate for your version of Eclipse and click OK.
You should see a “Groovy Update Site” entry in the list of update sites. Expand and select the Groovy-Eclipse Plugin
feature. Optionally, you can choose to include the sources..
Click Install and follow the prompts.
Restart when asked
Rejoice! You installed the Groovy-Eclipse Plugin.

Developer Resources

Source code hosted on GitHub
The Bamboo CI Server for Groovy-Eclipse.
Submit bugs on the Codehaus Jira Issue Tracker.
How to [[Update Greclipse to a New Groovy Compiler Version|Updating the groovy in groovy eclipse]]
Overview of [[Groovy Eclipse Architecture]]
How to [[Build the Maven Batch Compiler|Building Maven Batch Compiler]]
[[Release Build Process]]

这里写图片描述

这里写图片描述

由于我这里下载成功,无法显示Next的按钮,可能由于网速原因会出现下载失败,但是由于我的不放弃的精神,终于经过多次下载失败之后,成功下载。。。虽然一度使Eclispe启动失败。。。

下载成功之后将会出现

这里写图片描述

猜你喜欢

转载自blog.csdn.net/u013803499/article/details/54613968
今日推荐