Groovy java idea_IntelliJ IDEA Groovy(转)

更新环境变量:

source /etc/profile

验证是否成功:

# groovy -version

Groovy Version: 2.3.6 JVM: 1.7.0_67 Vendor: Oracle Corporation OS: Linux

打开groovyConsole:

2c7f83c1271204d3b8b2a10c6a60f0ba.png

4)、使用IDE进行开发(这里以Intellij idea 13.1为例)

1. Enable the plugin

Before you create your first Groovy application make sure Groovy plugin is enabled in Settings → Plugins.

caa3bc0943587462679e92e62117a2da.png

2. Create a new project

Open Project Wizard and select Scala template. Since Groovy requires Java you have to specify the Project SDK.

9e657a0ed87583d95841c86f4157f409.png

If you create a Groovy project for the first time IntelliJ IDEA will offer you to create Groovy SDK library. Press Create button and choose directory with a Groovy SDK.

f14e2c9a9b378436da46fefaaf43cc4a.png

The IDE will create an empty project.

5632b0f7107aae80f318f407723e0191.png

3. Create a new class

The easiest way to create Groovy class or script is to use Ctrl + N shortcut from Project View or Navigation Bar.

3ed960b650e309fe71b871f8c4185d65.png

Choose between class, interface, enum and annotation with Up and Down arrows.

ef98b81976039f0e28a5c27d60aec426.png

Let's create a class with a method returning 'Hello, world!' string.

5237fb759aa3331d29e73454505b2d26.png

4. Create a new script

Now we can create a script file via Ctrl + N shortcut.

b8e9a5711c961377e2cd312335d5a0f0.png

Choose between script and GroovyDSL script with Up and Down arrows.

e7ffeac64972179184ff366133f25e84.png

Now we can create an instance of our class and invoke hello method.

5. Run the project

In order to run the application you can manually create a Run configuration via Run → Edit configurations or run the active script automatically by pressing Ctrl + Shift + F10 shortcut.

9dd59ffe4610b9932f238a3c64c3abfd.png

使用Groovy Shell :

打开Tools-->Groovy Shell...

873ef7b65e82d8ded2157907cf54998c.png

使用Groovy Console :

打开Tools-->Groovy Console...

9e93832a785bfea2ca28ac4660b43d00.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值