Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing Spring AOP libraries in STS

I'm getting my feet wet with Spring. I downloaded STS and I'm following basic examples from Spring in Action Second Edition. I'm stuck when trying to implement basic AOP and I guess I'm just missing some specific libraries in my project.

I say so because annotations like @Aspect are not recognized in my classes like also <aop:config> in my xml.

This are my Maven Dependencies:

  • junit-4.7.jar
  • spring-test-3.0.2.RELEASE.jar
  • spring-context-3.0.2.RELEASE.jar
  • spring-aop-3.0.2.RELEASE.jar
  • aopalliance-1.0.jar
  • spring-beans-3.0.2.RELEASE.jar
  • spring-core-3.0.2.RELEASE.jar
  • commons-logging-1.1.1.jar
  • spring-expression-3.0.2.RELEASE.jar
  • spring-asm-3.0.2.RELEASE.jar
  • log4j-1.2.14.jar

Please let me know what libraries I'm missing and where to find them.

Thank you!

EDIT:

The following:

<bean id="performancePointcut"
        class="org.springframework.aop.aspectj.AspectJExpressionPointcut" >
    <property name="expression" value="execution(* Performer+.perform(..))" />
</bean>

throws the following exception:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'performancePointcut' defined in file [C:\Users\Prova\Documents\STS\SpringIdol3\src\main\resources\META-INF\spring\spring-idol.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException

DONE!

This aspectj-annotation-tutorial did the job with steps 1, 2, and 3.

It's been a fun Friday night....

like image 999
Marsellus Wallace Avatar asked Dec 05 '22 21:12

Marsellus Wallace


1 Answers

Put these two dependencies in your pom.xml:

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.6.11</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.6.11</version>
    </dependency>
like image 63
abalogh Avatar answered Dec 15 '22 02:12

abalogh