Hi,
I'm trying to do some hello world test in scala, here're code:
class HelloWorld {
def sayHello() : Unit = println("Hello word")
}
@Aspect
class HelloAspect {
@Around(value = "execution (* com.leon.aop.HelloWorld.sayHello())")
def testCP(jp: ProceedingJoinPoint) {
println("Start...")
jp.proceed()
println("End...")
}
}
myaop.xml:
<aspectj>
<aspects>
<aspect name="com.leon.aop.HelloAspect"/>
</aspects>
<weaver options="-XnoInline">
<include within="com.leon.aop.HelloWorld"/>
</weaver>
</aspectj>
launcher VM settings:
-javaagent:C:\Users\lma\.ivy2\cache\org.aspectj\aspectjweaver\jars\aspectjweaver-1.7.4.jar -Dorg.aspectj.weaver.loadtime.configuration=META-INF/myaop.xml
Testing class:
class HelloAspectTest extends FlatSpecLike with Matchers {
"HelloAspect" should "work" in {
val t = new HelloWorld
t.sayHello()
}
}
Yet I got below exception:
An exception or error caused a run to abort: com.leon.aop.HelloAspect.aspectOf()Lcom/leon/aop/HelloAspect;
java.lang.NoSuchMethodError: com.leon.aop.HelloAspect.aspectOf()Lcom/leon/aop/HelloAspect;
at com.leon.aop.HelloWorld.sayHello(HelloWorld.scala:7)
at com.leon.aop.HelloAspectTest$$anonfun$1.apply$mcV$sp(HelloAspectTest.scala:15)
at com.leon.aop.HelloAspectTest$$anonfun$1.apply(HelloAspectTest.scala:13)
at com.leon.aop.HelloAspectTest$$anonfun$1.apply(HelloAspectTest.scala:13)
Anyone could help me on this?
Thank
Leon