更新環境變量:html
source /etc/profile
驗證是否成功:app
# groovy -version Groovy Version: 2.3.6 JVM: 1.7.0_67 Vendor: Oracle Corporation OS: Linux
打開groovyConsole:ide
Before you create your first Groovy application make sure Groovy plugin is enabled in Settings → Plugins.ui
Open Project Wizard and select Scala template. Since Groovy requires Java you have to specify the Project SDK.idea
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..net
The IDE will create an empty project.3d
The easiest way to create Groovy class or script is to use Ctrl + N shortcut from Project View or Navigation Bar.htm
Choose between class, interface, enum and annotation with Up and Down arrows.blog
Let's create a class with a method returning 'Hello, world!' string.ip
Now we can create a script file via Ctrl + N shortcut.
Choose between script and GroovyDSL script with Up and Down arrows.
Now we can create an instance of our class and invoke hello method.
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.
使用Groovy Shell :
打開Tools-->Groovy Shell...
使用Groovy Console :
打開Tools-->Groovy Console...