Spring使用groovy作为bean,官方用了lang标签,但都是一个个文件。Groovy本身编译成class文件后当然可以和Java完全一样可以被component-scan。但是我想实现能够扫描groovy文件,并且groovy文件发生修改时候能够重新load(方便开发环境中提高效率),网上查查了,然后自己摸索了下,简单实现了。思路:1. 通过NamespaceHandlerSupport自己写一个parser,parser和已有的component-scan的区别就是修改了ClassPathBeanDefinitionScanne...
package ch5numbers = [11, 12, 13, 14]def staffTel = [‘Ken‘ : 2745, ‘John‘ : 2746, ‘Jessie‘ : 2772]println("Numbers:${numbers}") //双引号中的内容会被解释println(‘Staff telephone:${staffTel}‘) //单引号中的内容不会被解释printf(‘My name is Ken‘, [])printf(‘My name is Ken\n‘, [])def a = 10def b = 15printf("The sum of %d and %d is %d \n", [a, b, a + b])def x = 1.234def y = 56.78printf(‘%f f...
。Groovy插件的地址:http://dist.springsource.org/release/GRECLIPSE/e4.3/Next>>Finish原文:http://my.oschina.net/u/994490/blog/487693
java环境中基于jvm的两大语言:scala,groovy可以在java项目里混编这两种语言;scala:静态语言,多范式语言,糅合了面向对象、面向过程;可以与java和net互操作;融汇了众多的语言特性,包括类似net的闭包、lambda表达式;正是语言特性较多,语言复杂度也较高~~groovy:动态语言,既可作为面向对象语言又可做脚本语言;拥有动态语言的好处;语法简单~~scala、groovy都是作为java的替代语言,基于jdk1.6可以使用起来像jdk1.8的高级语...
log.info "starting"
// we use class to create objects of a class
Planet p1 = new Planet()
Planet p2 = new Planet()
Planet p3 = new Planet()//Planet.name = "Pluto" illegalPlanet.shape = "Circle" p1.name = "earth"
//p1.shape = "circle"p2.name = "jupiter"
//p2.shape = "circle"p3.name = "mars"
//p3.shape = "circle"log.info p1.name+" "+p1.shape
log.info p2.name+" "+p2.shape
log.info p3.name+" "+p3...
s import net.grinder.script.Barrier
import net.grinder.script.GTest
import net.grinder.scriptengine.groovy.junit.GrinderRunner
import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
import net.grinder.scriptengine.groovy.junit.annotation.Repeat
import org.junit.Before
import org.junit.Test
import org.junit.runner.R...
Groovy作为一种JVM-Based语言,目前普及程度正在提高。本文演示一下在Java类中,通过继承GDK的groovy.lang.Script类如何支持自定义表达式解析功能。 输入: 表示一行数据的某个map结构。在实际应用中,产生这种结构的最常见场景可能是通过JDBC访问数据库、通过调用WebService服务得到的某行结果集等。目标设定: 假设我们希望对输入数据进行某个运算。此处示例中,我们模拟oracle中最常用的nvl函数。 处理过程: 首先,通过继...
比较完常见后置处理器的性能之后,又顺便比较了下Groovy和BeanShell2者都是基于JVM的脚本语言,2者都能直接用Java的语法和类库这些国外网站都推荐用Groovy:http://jmeter.apache.org/usermanual/best-practices.htmlhttp://www.ubik-ingenierie.com/blog/magento-performance-toolkit-and-jmeter-best-practices/https://blazemeter.com/blog/beanshell-vs-jsr223-vs-java-jmeter-scripting-its-performance因为JMeter支持的一堆脚...
有时候遇到jenkins 的build result并不是真正想要的状态,比如check是否有代码更新,如果没有代码更新,build result为failed,但是其实并没有编译,failed状态会造成误解。想要把failed强制改成success。可以使用Groovy强制修改状态。使用Groovy postbuild插件 import hudson.model.Result
String desc = "Build Skipped"
manager.build.setDescription(desc)
manager.build.@result = hudson.model.Result.SUCCESS
jenkins自带...
转载自http://www.tuicool.com/articles/jYzuAv和http://www.importnew.com/1537.html在我与Martin Fowler曾经合作呈现的一次主题演讲中,他作出了一个有洞察性的观点:Java的遗产将是平台,而不是程序设计语言。Java技术的原始工程师们作出了一个明智的决定,就是将编程语言与运行时环境分开,最终这使得超过200种语言能够运行在Java平台上。这种架构对于该平台的长期活力是至关重要的,因为计算机程序设计语言的寿命一般都是比较...
Planet.log = loglog.info "starting"
// we use class to create objects of a class
Planet p1 = new Planet()
Planet p2 = new Planet()
Planet p3 = new Planet()//Planet.name = "Pluto" illegalPlanet.shape = "Circle" p1.name = "earth"
//p1.shape = "circle"p2.name = "jupiter"
//p2.shape = "circle"p3.name = "mars"
//p3.shape = "circle"log.info p1.name+" "+p1.shape
log.info p2.name+" "+p2.shape
log.info...
一、拦截方法调用和参数获取 示例1: class MyClass{
def hello(){
‘invoked hello directly‘
}
def invokeMethod(String name, Object args){
return "unknown method $name(${args.join(‘, ‘)})"
}
}
def mine= new MyClass()
assert mine.hello() == ‘invoked hello directly‘
assert mine.foo("Mark", 19) == ‘unknown method foo(Mark, 19)‘ 首先我们在groovy脚本中定义了一个Myclass对象,在groovy中任何的...
1.maven引入groovy jar包 <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>2.1.9</version> </dependency>2.调用 import groovy.lang.GroovyShell;public class TestGroovy { public static void main(String[] args) { // TODO Auto-generated method stub GroovyShell groovyShell = new GroovyShell(); Object resultObj; int x = 1; groovyShell.setVaria...
<dependency><groupId>fishman</groupId><artifactId>JMJ_API</artifactId><version>1.0</version><scope>system</scope><systemPath>${project.basedir}/lib/JMJ_API.jar</systemPath>
</dependency>注意1.<scope>system</scope>2.<systemPath>${project.basedir}/lib/JMJ_API.jar</systemPath> 原文:http://www.cnblogs.com/duwenlei/p/3810082.html
Java的东西Groovy都能用,包括语法和类库public static void main(String[] args) {// 重要的事情说3遍for (int i = 0; i < 3; i++) {System.out.println("Java的东西Groovy都能用");}// 再3遍for (i in 0..2) {println ‘Java的东西Groovy都能用‘}// 又3遍3.times {println ‘Java的东西Groovy都能用‘}
}1)Groovy继承了Java的所有东西,就是你突然忘了Groovy的语法可以写成Java代码,也就是Groovy和Java混在一起也能执行。2)G...