Search code examples
springaopaspectj

Spring STS doesn't recognize 'pointcut' keyword


I'm trying to create a simple aspect but my STS doesn't recognize the 'pointcut' keyword. I've installed all AspectJ plugins available but it made no difference.

Does anyone have I idea how can I get around this?

Thanks and Regards, Cristian


My aspect looks something like this:

public aspect LogAspect {
    pointcut method() : 
        (target(com.example.Class1)
        || target(com.example.Class2) )
        || execution (* com.example.controller.*.*(..));

}

Here is the error message:

enter image description here


Solution

  • I do not know STS, only Eclipse or IntelliJ IDEA. But STS is Eclipse-based, so I guess I know what went wrong.

    Have you maybe created the aspect via "New -> Class" instead of "New -> Aspect"? Then the file extension is *.java instead of *.aj. Just rename the file ion the console or in some kind of file manager (Windows Explorer or similar), then it will compile.


    Update 2016-02-06 13:48 CET: Assuming you have correctly installed AJDT, as you said, it looks as if you created a Java project instead of an AspectJ project. If the AspectJ nature is missing in your project, the nomal Java compiler will not recognise the aspect and show exactly that error message. Only the AspectJ compiler can parse AspectJ syntax.