问题贴在了https://stackoverflow.com/questions/74233815/meet-some-problems-about-aspectj-maven-plugin-and-aspectj上。
主要是想通过aspectj开发一个公共jar包用于各个项目的指定给组件的方法执行拦截,生成链路信息。
例如:目前开发了ProjectA作为公共jar包,包中对于logback的一些指定方法进行拦截,所以我在ProjectA中添加了如下代码
<dependency>
<groupId>ch.qos.logbackgroupId>
<artifactId>logback-classicartifactId>
<version>xxxversion>
dependency>
<plugin>
<groupId>org.codehaus.mojogroupId>
<artifactId>aspectj-maven-pluginartifactId>
<version>1.14.0version>
<configuration>
<showWeaveInfo>trueshowWeaveInfo>
<source>1.8source>
<target>1.8target>
<Xlint>ignoreXlint>
<complianceLevel>1.8complianceLevel>
<encoding>UTF-8encoding>
<verbose>trueverbose>
<weaveDependencies>
<weaveDependency>
<groupId>ch.qos.logbackgroupId>
<artifactId>logback-classicartifactId>
weaveDependency>
weaveDependencies>
configuration>
<executions>
<execution>
<phase>process-sourcesphase>
<goals>
<goal>compilegoal>
goals>
execution>
executions>
<dependencies>
<dependency>
<groupId>org.aspectjgroupId>
<artifactId>aspectjtoolsartifactId>
<version>1.9.7version>
dependency>
dependencies>
plugin>
并将其打成jar包,给ProjectB使用,在ProjectB中我添加了如下代码:
<dependency>
<groupId>xxxgroupId>
<artifactId>ProjectAartifactId>
<version>xxxversion>
dependency>
<plugin>
<groupId>org.codehaus.mojogroupId>
<artifactId>aspectj-maven-pluginartifactId>
<version>1.14.0version>
<configuration>
<showWeaveInfo>trueshowWeaveInfo>
<source>1.8source>
<target>1.8target>
<Xlint>ignoreXlint>
<complianceLevel>1.8complianceLevel>
<encoding>UTF-8encoding>
<verbose>trueverbose>
<aspectLibraries>
<aspectLibrary>
<groupId>xxxgroupId>
<artifactId>ProjectAartifactId>
aspectLibrary>
aspectLibraries>
configuration>
<executions>
<execution>
<phase>process-sourcesphase>
<goals>
<goal>compilegoal>
goals>
execution>
executions>
<dependencies>
<dependency>
<groupId>org.aspectjgroupId>
<artifactId>aspectjtoolsartifactId>
<version>1.9.7version>
dependency>
dependencies>
plugin>
在执行B项目的package的时候,期待的是可以对B中logback源码进行增强,但是却没有实现
现在就想问下:
思路稍微有点不对吧,你这用的是编译时植入,只对这个Project A打的包才有效果吧,你引用的项目无法变更吧,是不得写在一个parent的pom里面?
这个看看
https://blog.csdn.net/mamamalululu00000000/article/details/111264804