简体   繁体   中英

Can we apply AOP aspects to multi maven project

In my project we are using multi maven project that means there are multiple projects with in the same project. I tried to apply Logging using AOP in one of the project classes from one another project. Is there any way to apply AOP in these circumstances.

My project structure is like:

--Parent-pom project
  --child1-pom project
  --child2-pom project

My child1-pom project contains AOP class, where I have specified logging aspect as:

@Pointcut("execution(* com.test.web.SampleEntityController.test(..))")

My SampleEntityController class is present in child2-pom project . Now, STS shows warning on my pointcut that:

no match for this type name: com.test.web.SampleEntityController 
 [Xlint:invalidAbsoluteTypeName]

The build sequence for my project is child1 project ( jar ), followed by child2 project ( war packaging ). The child2.war contains jar file of child1.jar in web-inf/lib directory.

With Thanks, Sandeep Kapoor

In principle there is no issue in applying AOP across multiple projects. The only few things you need to take care of are:

  1. All the projects are present on the classpath
  2. If the projects execute seperately then each one should have spring AOP configured though the aspect may be declared only once.
  3. Spring should be loaded properly for the AOP to get executed.

If you need more details specific to your example, please provide the project structure with a brief description and I can tell you more about it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM